#!/bin/bash

# Example:
#     sh CBIG_gwMRF_unit_test.sh ~/storage/Temporary/CBIG_gwMRF_unit_test
#
# Written by <NAME> and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

user=`whoami`

###############################
# Set paths and create log file
###############################

# code_dir contains Schaefer2018 parcellation codes
code_dir=$CBIG_CODE_DIR/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal/Code

# data_dir contains data used by unit test
data_dir=$CBIG_TESTDATA_DIR/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal/data

# ref_dir contains reference results
ref_dir=$CBIG_TESTDATA_DIR/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal/results

# pass in output_dir
output_dir=`realpath ${1}`
mkdir -p ${output_dir}/logs
mkdir -p ${output_dir}/job_err_out

# create log file in output_dir
LF="${output_dir}/logs/CBIG_gwMRF_unit_test.log"
touch $LF
echo -e "Start CBIG_gwMRF_unit_test" >> $LF
date >> $LF
echo -e "\nOutput folder = ${output_dir}" >> $LF
echo -e "Reference folder = ${ref_dir} \n\n" >> $LF

###################################
# Generate example results
###################################

ex_output_dir=${output_dir}/example_out
ex_input_fullpath=${ex_output_dir}/example_input_fullpaths.csv

# specify input parameters
start_idx='1'
end_idx='2'
num_left_cluster='50'
num_right_cluster='50'
smoothcost='5000'
num_iterations='2'
num_runs='1'
start_gamma='50000000'
exponential='15'

my_cmd="cd ${code_dir};"
my_cmd="${my_cmd} matlab -nosplash -nodisplay -nodesktop -r "
my_cmd="${my_cmd} \"CBIG_gwMRF_build_data_and_perform_clustering ${ex_input_fullpath} ${ex_output_dir} \
 ${start_idx} ${end_idx} ${num_left_cluster} ${num_right_cluster} ${smoothcost} ${num_iterations} \
 ${num_runs} ${start_gamma} ${exponential}; exit;\" "

# submit job for generating example results
ERR_FILE_PATH="${ex_output_dir}/CBIG_gwMRF_example.err"
OUT_FILE_PATH="${ex_output_dir}/CBIG_gwMRF_example.out"

# this is to accomodate for new HPC
temp_script_file1="${ex_output_dir}/temp_script1.sh"
echo '#!/bin/bash ' >> ${temp_script_file1}
echo ${my_cmd} >> ${temp_script_file1}
chmod 755 ${temp_script_file1}

$CBIG_CODE_DIR/setup/CBIG_pbsubmit -cmd "${temp_script_file1}" -walltime 3:00:00 -mem 35G -name "gwMRF_ex" \
-joberr ${ERR_FILE_PATH} -jobout ${OUT_FILE_PATH}

# will not proceed to next step until the current job is successfully done
ex_out_name='Graph_Cut_faster__grad_prior_gordon_cluster_20_datacost_1_smoothcost_5000_iterations_2_seed_1.mat'
ex_out_file=${ex_output_dir}/clustering/${ex_out_name}
sh $CBIG_CODE_DIR/utilities/scripts/CBIG_check_job_status -n gwMRF_ex -o ${ex_out_file}

EXIT_STATUS=$?
if [[ "$EXIT_STATUS" -eq "1" ]]
then
	echo "Failed to generate example parcellations."
	exit 1
else
	echo "Successfully generated example results. Will proceed with the rest of the unit test..."
fi

####################################
# Create input time and mult matrix
####################################

# note that the mult matrix is generated based on the time matrix
# therefore we squash two matlab commands together
# we only checks the final mult matrix result, no need to check time matrix (extra complexity)

TIME_DATA_OUT="${output_dir}/time_data"
MULT_DATA_OUT="${output_dir}/mult_mat"

mkdir -p ${TIME_DATA_OUT}
mkdir -p ${MULT_DATA_OUT}

# specifiy job inputs for build time mat
input_fullpaths="${output_dir}/unit_tests_input_fullpaths_short.csv"
start_idx='1'
end_idx='2'
fsaverage='fsaverage6'
lh_output_file='lh_time_matrix.mat'
rh_output_file='rh_time_matrix.mat'

# specify job inputs for build mult mat
lh_input_filename="${output_dir}/time_data/lh_time_matrix.mat"
rh_input_filename="${output_dir}/time_data/rh_time_matrix.mat"
lh_output_filename='lh_mult_matrix.mat'
rh_output_filename='rh_mult_matrix.mat'

# create one matlab command that sequencially calls the 2 functions
# that build time matrix and mult matrix separately
my_cmd2="cd ${code_dir}/lib ;"
my_cmd2="${my_cmd2} matlab -nosplash -nodisplay -nodesktop -r "
my_cmd2="${my_cmd2} \"CBIG_gwMRF_build_time_matrix ${input_fullpaths} ${TIME_DATA_OUT} ${start_idx} \
 ${end_idx} ${fsaverage} ${lh_output_file} ${rh_output_file}; "
my_cmd2="${my_cmd2} CBIG_gwMRF_build_prod_matrix ${lh_input_filename} ${rh_input_filename} \
${MULT_DATA_OUT} ${lh_output_filename} ${rh_output_filename}; exit; \" "

# submit job for generating the time matrix
ERR_FILE_PATH="${output_dir}/job_err_out/CBIG_gwMRF_mult.err"
OUT_FILE_PATH="${output_dir}/job_err_out/CBIG_gwMRF_mult.out"

# this is to accomodate for new HPC
temp_script_file2="${output_dir}/temp_script2.sh"
echo '#!/bin/bash' >> ${temp_script_file2}
echo ${my_cmd2} >> ${temp_script_file2}
chmod 755 ${temp_script_file2}

$CBIG_CODE_DIR/setup/CBIG_pbsubmit -cmd "${temp_script_file2}" -walltime 1:00:00 -mem 15G -name "gwMRF_mult_mat" \
-joberr ${ERR_FILE_PATH} -jobout ${OUT_FILE_PATH}

# wait until the current job is done, by checking both the job name and the mult mat file
# we only check rh mult mat since it is generated after the lh mult mat
OUT_FILE_DIR="${output_dir}/mult_mat/rh_mult_matrix.mat"
sh $CBIG_CODE_DIR/utilities/scripts/CBIG_check_job_status -n 'gwMRF_mult_mat' -o ${OUT_FILE_DIR}

EXIT_STATUS=$?
if [[ "$EXIT_STATUS" -eq "1" ]]
then
	echo "[FAILED] Failed to generate multiplied matrices."
	exit 1
else
	echo "Successfully generated multiplied matrices. Will proceed with the rest of the unit test..."
fi

####################################################
# Generate intermediate RH parcellation for seed 2
####################################################

# in the function input below, note that we delibrately set 'iter_reduce_gamma' to 1
# since running the job to the end (iter_reduce_gamma = 300) will be very time consuming
# in the previous example, we have already run seed 1 to the end
# here, we only intend to test 1 more seed, thus 1 iteration is enough

vargin=" 'lh_avg_file' '${output_dir}/mult_mat/lh_mult_matrix.mat' \
  'rh_avg_file' '${output_dir}/mult_mat/rh_mult_matrix.mat' 'left_cluster' '50' 'right_cluster' \
  '50' 'iterations' '2' 'smoothcost' '1000' 'start_index' '2' 'runs' '1' 'output_folder' \
  '${output_dir}/clustering/' 'dim' '360' 'exponential' '15' 'start_gamma' '10000000' 'skip_left' '1' \
  'iter_reduce_gamma' '1' ";

PROJ_CODE_DIR="${CBIG_CODE_DIR}/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal/Code"

my_cmd3="cd ${code_dir}; "
my_cmd3="${my_cmd3} matlab -nosplash -nodisplay -nodesktop -r "
my_cmd3="${my_cmd3} \" addpath(genpath('${PROJ_CODE_DIR}'));"
my_cmd3="${my_cmd3} CBIG_gwMRF_graph_cut_clustering ${vargin}; exit; \" ";

# submit job for generating the time matrix
ERR_FILE_PATH="${output_dir}/job_err_out/CBIG_gwMRF_seed2.err"
OUT_FILE_PATH="${output_dir}/job_err_out/CBIG_gwMRF_seed2.out"

# this is to accomodate for new HPC
temp_script_file3="${output_dir}/temp_script3.sh"
echo '#!/bin/bash' >> ${temp_script_file3}
echo ${my_cmd3} >> ${temp_script_file3}
chmod 755 ${temp_script_file3}
$CBIG_CODE_DIR/setup/CBIG_pbsubmit -cmd "${temp_script_file3}" -walltime 1:00:00 -mem 15G -name "gwMRF_seed2" \
-joberr ${ERR_FILE_PATH} -jobout ${OUT_FILE_PATH}

##############################################
# Hold until first iteration results generated
##############################################
prefix=Graph_Cut_faster__grad_prior_gordon_cluster_20_datacost_1_smoothcost_1000_iterations_2
file_seed2=${output_dir}/clustering/inbetween_results/${prefix}_seed_2_rh_reduction_iteration_1.mat
sh $CBIG_CODE_DIR/utilities/scripts/CBIG_check_job_status -n 'gwMRF_seed2' -o ${file_seed2}

EXIT_STATUS=$?
if [[ "$EXIT_STATUS" -eq "1" ]]
then
	echo "[FAILED] Failed to generate results for seed 2."
	exit 1
else
	echo "Successfully generated results for seed 2. Will proceed with the rest of the unit test..."
fi

######################################################
# Compare results to check whether code pass unit test
######################################################

ERR_FILE_PATH=${output_dir}/job_err_out/CBIG_gwMRF_compare.err
OUT_FILE_PATH=${output_dir}/job_err_out/CBIG_gwMRF_compare.out

my_cmd4="cd `dirname $0`;"
my_cmd4="${my_cmd4} matlab -nosplash -nodisplay -nodesktop -r "
my_cmd4="${my_cmd4} \" clear;clc;close all;CBIG_gwMRF_check_unit_test_result '${output_dir}';exit; \" >> $LF "

# this is to accomodate for new HPC
temp_script_file4="${output_dir}/temp_script4.sh"

echo '#!/bin/bash' >> ${temp_script_file4}
echo ${my_cmd4} >> ${temp_script_file4}
chmod 755 ${temp_script_file4}
$CBIG_CODE_DIR/setup/CBIG_pbsubmit -cmd "${temp_script_file4}" -walltime 1:00:00 -mem 30G -name "gwMRF_compare" \
-joberr ${ERR_FILE_PATH} -jobout ${OUT_FILE_PATH}

# hold until job is finished
sh $CBIG_CODE_DIR/utilities/scripts/CBIG_check_job_status -n 'gwMRF_compare'

# remove temporary scripts for pb_submit
rm ${temp_script_file1}
rm ${temp_script_file2}
rm ${temp_script_file3}
rm ${temp_script_file4}

# check if job contains no failure | is run to the end
fail=`grep FAILED $LF | wc -l`
done=`grep DONE $LF | wc -l`
if [ $fail -gt 0 ] || [ $done -eq 0 ]; then
	echo "[FAILED] Job is unsuccessful. Check log file: $LF."
	exit 1
fi

##################
# End of unit test
##################

echo -e "\nEnd CBIG_gwMRF_unit_test" >> $LF
date >> $LF
echo -e "====================================================================\n\n" >> $LF


<filename>Average_GC_Content_Analysis/knowGC-contentrun1.sh

##Source: http://wiki.bits.vib.be/index.php/Create_a_GC_content_track

##Descrption: Takes the fasta, 1) Generates Non-overlapping Sliding windows,
#       		       2) Checks if the Sliding windows has N's and ignores if is more than default
# 			       3)Outputs the GC% content in each sliding window

#Dependencies: Bedtools,knowGC-contentHistogramrun2.pl (the other sister script in the same folder)

##Script compiled by: <NAME>

##Date: August 06, 2014

##Email: <EMAIL> // <EMAIL>

## Usage: ./knowGC-contentrun1.sh <fileName.fasta> <windowsize>

filefasta="$1"; ##input fasta file
echo "Input file is: $filefasta"

width=$2 ##default
echo "Sliding window is: $width"

MaxN=`expr $width \* 25 / 100` ##more than 25% N's in the sliding window are ignored.
echo "Number of N's allowed in ${width} Sliding window: $MaxN"

	##step1

	echo "Checking fasta sequence sizes..1/4"
	faSize ${filefasta} -detailed > ${filefasta}.sizes

	##step2

	echo "Making windows..2/4"
	bedtools makewindows -g ${filefasta}.sizes -w ${width} > ${filefasta}.sizes.${width}.window.bed

	##step3

	echo "Extracting sliding window sequence..3/4"
	bedtools nuc -fi ${filefasta} -bed ${filefasta}.sizes.${width}.window.bed -seq >${filefasta}.sizes.${width}.window.bed.nuc.out

	##step4

	echo "AWKING to get sliding windows with N's < 25% of the sliding window length..4/4"
	rm ${filefasta}.window${width}.GC-content.txt ##Deleting previous existing same files
	head -1 ${filefasta}.sizes.${width}.window.bed.nuc.out >${filefasta}.window${width}.GC-content.txt

	awk 'NR>1' ${filefasta}.sizes.${width}.window.bed.nuc.out | awk -v var1=${width} '$3-$2==var1 {print $0;}'  | awk -v var2=${MaxN} '$10 <= var2' | awk '{$NF=""}1' >>${filefasta}.window${width}.GC-content.txt ##1st awk checks if the windows is 20kb, 2nd awk checks if the N's in the window are less than 25% of the 20kb, 3rd awk ignores the sliding window sequence and output the file.(..window size is 20kb, 25% of 20kb is 5k)

	echo "Completed with Bedtools, Now calculating Intervals and proportions";

	##step 5
	awk '{print $5}' ${filefasta}.window${width}.GC-content.txt | awk 'NR>1' >${filefasta}.window${width}.GC-content.txt.in

	##step6

	perl knowGC-contentHistogramrun2.pl ${filefasta}.window${width}.GC-content.txt.in 0 1 0.05 >${filefasta}.window${width}.GC-content.txt.out


#!/bin/bash

# Copyright 2017 Istio Authors

#   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 to do repo init equivalent

# Exit immediately for non zero status
set -e
# Check unset variables
set -u
# Print commands
set -x

function checkout_code() {
  local REPO=$1
  local REPO_SHA=$2
  local BRANCH=$3
  local DIR=$4

  mkdir -p "${DIR}"
  pushd    "${DIR}"
    git clone "https://github.com/istio/$REPO" -b "${BRANCH}"
    pushd "${REPO}"
    git checkout "${REPO_SHA}"
    popd
  popd
}

function istio_code_init_manifest() {
  local BRANCH=$1
  local MANIFEST_FILE=$2

  ISTIO_SHA=$(grep "istio/istio" "$MANIFEST_FILE" | cut -f 6 -d \")
  API_SHA=$(  grep "istio/api"   "$MANIFEST_FILE" | cut -f 6 -d \")
  PROXY_SHA=$(grep "istio/proxy" "$MANIFEST_FILE" | cut -f 6 -d \")

  checkout_code "proxy" "${PROXY_SHA}" "${BRANCH}" "/workspace/src"
  checkout_code "api"     "${API_SHA}" "${BRANCH}" "/workspace/go/src/istio.io"
  checkout_code "istio" "${ISTIO_SHA}" "${BRANCH}" "/workspace/go/src/istio.io"
}

BRANCH=""
GCS_RELEASE_TOOLS_PATH=""

function usage() {
  echo "$0
    -b <name>       branch                              (required)
    -r <url>        directory path to release tools     (required)"
  exit 1
}

while getopts b:r: arg ; do
  case "${arg}" in
    b) BRANCH="${OPTARG}";;
    r) GCS_RELEASE_TOOLS_PATH="${OPTARG}";;
    *) usage;;
  esac
done

[[ -z "${BRANCH}"                 ]] && usage
[[ -z "${GCS_RELEASE_TOOLS_PATH}" ]] && usage

MANIFEST_URL="${GCS_RELEASE_TOOLS_PATH}/manifest.xml"
gsutil cp                "gs://${MANIFEST_URL}" "/output/manifest.xml" || echo ""

MANIFEST_LOCAL_FILE="/output/manifest.xml"
gsutil cp                "gs://${MANIFEST_URL}" "${MANIFEST_LOCAL_FILE}"
istio_code_init_manifest      "${BRANCH}"       "${MANIFEST_LOCAL_FILE}"
exit 0


<reponame>gigayak/buildsystem
#!/bin/bash
set -Eeo pipefail

cd "$YAK_WORKSPACE"
version=1.4.1
echo "$version" > "$YAK_WORKSPACE/version"
urldir="http://download.savannah.gnu.org/releases/libpipeline"
url="$urldir/libpipeline-${version}.tar.gz"
wget "$url"
tar -zxf *.tar.*

cd *-*/
./configure \
  --prefix=/usr
make


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

# Provides json output for ansible '--list' request
if [ "$1" = "--list" ]; then
  cat ./inventory.json
fi


<reponame>qtweng/f1tenth-gym<gh_stars>0
#!/bin/bash

set -o errexit

unset username
unset pass
unset description

printf "This script will compile your project & upload to Riders.ai for evaluation.\n"
printf "Please enter your Riders.ai Username & Password\n\n"

echo -n "Username:"
read username
echo -n "Password:"
read -s pass

SCRIPT_DIR=$(dirname "$0")

cd $SCRIPT_DIR/..

set -a # automatically export all variables
source ./.env
set +a

printf "\nRetrieving your API Token...\n"

RED='\033[0;31m'
NC='\033[0m' # No Color

DATA='{"username": '\""$username"\"', "password": '\""<PASSWORD>"\"'}'

COLAB_HOST="$RIDERS_API_HOST"'/get-token/'

COLAB_TOKEN_RESPONSE=$(curl -H "Content-Type: application/json" -X POST -d "$DATA" "$COLAB_HOST")

STATUS_CODE=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Content-Type: application/json" -X POST -d "$DATA" "$COLAB_HOST")

if [ $STATUS_CODE == "404" ]; then
  echo -e "${RED}Authorization Failed: Token Not Found"
  exit 1
elif [ $STATUS_CODE == "403" ]; then
  echo "${RED}Too Many Attemps, Please contact with Riders.ai admins"
  exit 1
elif [ $STATUS_CODE == "200" ]; then
  echo "Authorization Successful"
fi

RIDERS_AUTH_TOKEN=$(echo $COLAB_TOKEN_RESPONSE | jq -c '.token' | tr -d '"')
if [[ -z ${RIDERS_AUTH_TOKEN} ]]; then
  printf "Faulty Auth Token, please try restarting this script.\n"
  exit
fi

# TODO: bir onceki satir eger hata donerse exit code, none 0 olmali, if so display error

printf "\n\nBuilding your Agent Docker image, this may take a while...\n"

# Try to build agent locally to prevent sending user_projects that fail on build process.
docker-compose build agent

# We assume this script was placed on the project root. Otherwise we should change directory.
# Archive tar file with arbitrary filename
printf "\n\nBuilding TAR file, this may take a while...\n"
git ls-files | tar Tzcf - challengeproject.tar
printf "Compiled TAR file for submission.\n"

printf "\n\nPlease enter a short description of your submission. This would help you compare separate submissions\n"
echo -n "Description:"
read description

F1TENTH_RIDERS_API="$RIDERS_F1TENTH_HOST"'/update'

# TODO: Fix arbitrary constants
curl --location \
    -F 'file=@./challengeproject.tar' \
    -F description="$description" \
    -F challenge=$RIDERS_CHALLENGE_ID \
    -F token='Token '$RIDERS_AUTH_TOKEN \
    -F api_host=$RIDERS_API_HOST \
    "$F1TENTH_RIDERS_API"

#if [ $F1TENTH_STATUS_CODE == "403" ]; then
#  echo -e "${RED}Upload Project Failed: User can not join challenge"
#  exit 1
#elif [ $F1TENTH_STATUS_CODE == "200" ]; then
#  echo "Project Has Been Uploaded"
#fi


echo "Stop"
sudo pkill node
sudo systemctl stop som-web-ssr


#!/usr/bin/env -S bash ../.port_include.sh
port=SDL2_ttf
version=2.0.15
useconfigure=true
files="https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-${version}.tar.gz SDL2_ttf-${version}.tar.gz"
workdir="SDL2_ttf-$version"
depends="SDL2 freetype"

configure() {
    run ./configure \
        --host=${SERENITY_ARCH}-pc-serenity \
        --with-sdl-prefix=${SERENITY_ROOT}/Build/Root/usr \
        LIBS="-lgui -lgfx -lipc -lcore -lcompress"
}


#!/bin/bash

dir=`pwd`
bin=$dir/../programs
list=$dir/../data/sequin.list
datadir=$dir/../data/sequin
results=$dir/../results/sequin
mkdir -p $results

scripts=`tempfile -d $dir`
rm -f $scripts

function make.scripts
{
	algo=$1;
	suffix=$2;
	coverage=$3;

	if [ ! -x $bin/$1 ]; then
		echo "please make sure $bin/scallop is available/executable"
		exit
	fi

	if [ ! -x $bin/gffcompare ]; then
		echo "please make sure $bin/gffcompare is available/executable"
		exit
	fi

	aligns="tophat star hisat"

	if [ "$1" == "transcomb" ]; then
		aligns="tophat star"
	fi

	for x in `cat $list`
	do
		id=`echo $x | cut -f 1 -d ":"`
		ss=`echo $x | cut -f 2 -d ":"`
		gm=`echo $x | cut -f 3 -d ":"`
		gtf=$dir/../data/ensembl/$gm.gtf

		if [ ! -s $gtf ]; then
			echo "make sure $gtf is available"
			exit
		fi

		for aa in `echo $aligns`
		do
			bam=$datadir/$id/$aa.sort.bam

			if [ ! -s $bam ]; then
				echo "make sure $bam is available"
				exit
			fi

			cur=$results/$id.$aa/$algo.$suffix

			echo "./run.$algo.sh $cur $bam $gtf $coverage $ss" >> $scripts
		done
	done
}

## MODIFY THE FOLLOWING LINES TO SPECIFIY EXPERIMENTS
#usage: make.scripts <scallop|stringtie|transcomb> <ID of this run> <minimum-coverage>
make.scripts scallop test1 1.0
#make.scripts stringtie test1 2.5
#make.scripts transcomb test1 0.01

xarglist=`tempfile -d $dir`
rm -f $xarglist

cat $scripts | sort -R > $xarglist

## MODIFY -P TO SPECIFY CPU CORES
nohup cat $xarglist | xargs -L 1 -I CMD -P 10 bash -c CMD > /tmp/null &


<reponame>kamal2222ahmed/jiffy-web
#  Copyright 2008 Whitepages.com, Inc. See License.txt for more information.

#!/bin/sh

usage()
{
  echo "Usage: gen_jiffy_dw_schema_oracle.sh [config]"
  echo "  DDL to create data warehouse star schema for jiffy rollup reporting"
}

if [ $# != 1 ]
then
  usage
  exit
else
  CONFIG=$1
fi

OUT1=create_jiffy_dw_schema.sql
OUT2=create_jiffy_rollup_package.sql

get()
{
  grep "$1" $CONFIG | cut -d= -f2
}

# get Oracle configurations
DATA_TABLESPACE=$(get DATA_TABLESPACE)
DATA_FILENAME=$(get DATA_FILENAME)
DATA_FILESIZE=$(get DATA_FILESIZE)
INDEX_TABLESPACE=$(get INDEX_TABLESPACE)
INDEX_FILENAME=$(get INDEX_FILENAME)
INDEX_FILESIZE=$(get INDEX_FILESIZE)
USE_BITMAP_INDEX=$(get USE_BITMAP_INDEX)

JIFFY_USERNAME=$(get JIFFY_USERNAME)
JIFFY_PASS=$(get JIFFY_PASS)
JIFFY_LOADER_USERNAME=$(get JIFFY_LOADER_USERNAME)
JIFFY_LOADER_PASS=$(get JIFFY_LOADER_PASS)
JIFFY_READER_USERNAME=$(get JIFFY_READER_USERNAME)
JIFFY_READER_PASS=$(get JIFFY_READER_PASS)
TEMPORARY_TABLESPACE=$(get TEMPORARY_TABLESPACE)
CONNECTSTRING=$(get CONNECTSTRING)

EMAIL_FROM=$(get EMAIL_FROM)
EMAIL_TO=$(get EMAIL_TO)

echo ""
echo ""
echo "You have enter the following setttings:"
echo ""
echo "DATABASE=$DATABASE"
echo "JIFFY_USERNAME=$JIFFY_USERNAME"
echo "JIFFY_PASS=$<PASSWORD>"
echo "CONNECTSTRING=$CONNECTSTRING"
echo "USE_BITMAP_INDEX=$USE_BITMAP_INDEX"
echo ""
echo "Press enter to confirm your setting "
#read dummy

#
# Begin creating schema
#

echo "
CONNECT ${JIFFY_USERNAME}/${JIFFY_PASS}@${CONNECTSTRING};
--
--  TABLE OWNER ${JIFFY_USERNAME}
--
BEGIN EXECUTE IMMEDIATE 'DROP TABLE measurement_facts';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE TABLE measurement_facts
(
    d_time_id       DATE    NOT NULL,   -- DATETIME is a natural unique key and easily indexed
    d_code_id       NUMBER  NOT NULL,
    d_page_id       NUMBER  NOT NULL,
    d_cat1_id       NUMBER  NULL, -- awaiting support for this dimension
    d_cat2_id       NUMBER  NULL, -- awaiting support for this dimension
    d_os_id         NUMBER  NULL, -- awaiting support for this dimension
    d_browser_id    NUMBER  NULL, -- awaiting support for this dimension
    et_count        NUMBER,
    et_sum          NUMBER,
    et_sum_squares  NUMBER,
    -- et_mean and et_std are functionall derived from sum, count, and sum of squares
    et_min          NUMBER,
    et_max          NUMBER,
    CONSTRAINT measurement_facts_pk PRIMARY KEY
    (
        d_time_id,
        d_code_id,
        d_page_id,
        d_cat1_id,
        d_cat2_id,
        d_os_id,
        d_browser_id
    ) USING INDEX TABLESPACE ${INDEX_TABLESPACE}
);

GRANT SELECT, UPDATE, INSERT ON measurement_facts TO ${JIFFY_LOADER_USERNAME};
GRANT SELECT ON measurement_facts TO ${JIFFY_READER_USERNAME};

-- create indexes on facts for each dimension
-- time dimension is too fine grained to use bitmaps space efficiently
CREATE INDEX mf_time_ix
    ON measurement_facts (d_time_id)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX mf_code_ix
    ON measurement_facts (d_code_id)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX mf_page_ix
    ON measurement_facts (d_page_id)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX mf_cat1_ix
    ON measurement_facts (d_cat1_id)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX mf_cat2_ix
    ON measurement_facts (d_cat2_id)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX mf_os_ix
    ON measurement_facts (d_os_id)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX mf_browser_ix
    ON measurement_facts (d_browser_id)
    TABLESPACE ${INDEX_TABLESPACE};

-- sequences for dimension ids
BEGIN EXECUTE IMMEDIATE 'DROP SEQUENCE code_id_seq';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE SEQUENCE code_id_seq INCREMENT BY 1 START WITH 1;

BEGIN EXECUTE IMMEDIATE 'DROP SEQUENCE page_id_seq';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE SEQUENCE page_id_seq INCREMENT BY 1 START WITH 1;

BEGIN EXECUTE IMMEDIATE 'DROP SEQUENCE cat1_id_seq';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE SEQUENCE cat1_id_seq INCREMENT BY 1 START WITH 1;

BEGIN EXECUTE IMMEDIATE 'DROP SEQUENCE cat2_id_seq';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE SEQUENCE cat2_id_seq INCREMENT BY 1 START WITH 1;

BEGIN EXECUTE IMMEDIATE 'DROP SEQUENCE os_id_seq';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE SEQUENCE os_id_seq INCREMENT BY 1 START WITH 1;

BEGIN EXECUTE IMMEDIATE 'DROP SEQUENCE browser_id_seq';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE SEQUENCE browser_id_seq INCREMENT BY 1 START WITH 1;

-- time dimension
BEGIN EXECUTE IMMEDIATE 'DROP TABLE d_time';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE TABLE d_time (
    time_id     DATE         NOT NULL,   -- key is time TRUNCed to smallest interval (1 minute)
    -- foo_dt is time_id TRUNCed to foo interval
    yyyy        NUMBER(4)    NOT NULL,
    yyyy_dt     DATE         NOT NULL,
    mm          NUMBER(2)    NOT NULL, -- [1..12]
    mm_dt       DATE         NOT NULL,
    mon         VARCHAR2(3)  NOT NULL, -- [Jan..Dec]
    month       VARCHAR2(10) NOT NULL, -- [January..December]
    dd          NUMBER(2)    NOT NULL, -- [1..31]
    dd_dt       DATE         NOT NULL,
    hr          NUMBER(2)    NOT NULL, -- [00..23]
    hr_dt       DATE         NOT NULL,
    mi          NUMBER(2)    NOT NULL, -- [00..59]
    -- mi_dt is the same as time_id
    qtr         NUMBER(1)    NOT NULL, -- [1..4]
    qtr_dt      DATE         NOT NULL,
    iwk         NUMBER(2)    NOT NULL, -- [1..52]
    iwk_dt      DATE         NOT NULL,
    day_of_wk   NUMBER(1)    NOT NULL, -- [1..7]
    day_abbrv   VARCHAR2(3)  NOT NULL, -- [Sun..Sat]
    day_name    VARCHAR2(10) NOT NULL, -- [Sunday..Saturday]
    -- day/time characteristic periods
    weekend     NUMBER(1)    NOT NULL, -- 1=>true
    holiday     NUMBER(1)    NOT NULL, -- 1=>true
    morning     NUMBER(1)    NOT NULL, -- 1=>6am..noon
    afternoon   NUMBER(1)    NOT NULL, -- 1=>noon..6pm
    evening     NUMBER(1)    NOT NULL, -- 1=>6pm..midnight
    night       NUMBER(1)    NOT NULL, -- 1=>midnight..6am
    worktime    NUMBER(1)    NOT NULL, -- 1=>8am..5pm
    -- time intervals
    mi5         number(3)    NOT NULL, -- index of 5minute intervals in day [0..287]
    mi5_dt      DATE         NOT NULL,
    mi10        number(3)    NOT NULL, -- index of 10minute intervals in day [0..143]
    mi10_dt     DATE         NOT NULL,
    mi15        number(2)    NOT NULL, -- index of 15minute intervals in day [0..95]
    mi15_dt     DATE         NOT NULL,
    mi30        number(2)    NOT NULL, -- index of 30minute intervals in day [0..47]
    mi30_dt     DATE         NOT NULL,
    hr2         number(2)    NOT NULL, -- index of 2hour intervals in day [0..11]
    hr2_dt      DATE         NOT NULL,
    hr3         number(1)    NOT NULL, -- index of 3hour intervals in day [0..7]
    hr3_dt      DATE         NOT NULL,
    hr6         number(1)    NOT NULL, -- index of 6hour intervals in day [0..3]
    hr6_dt      DATE         NOT NULL,
    hr12        number(1)    NOT NULL, -- index of 6hour intervals in day [0..1]
    hr12_dt     DATE         NOT NULL,
    CONSTRAINT d_time_pk PRIMARY KEY
    (
        time_id
    ) USING INDEX TABLESPACE ${INDEX_TABLESPACE}
);

CREATE ${USE_BITMAP_INDEX} INDEX dt_yyyy_ix ON d_time (yyyy) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_yyyy_dt_ix ON d_time (yyyy_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_mm_ix ON d_time (mm) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mm_dt_ix ON d_time (mm_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_mon_ix ON d_time (mon) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_month_ix ON d_time (month) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_dd_ix ON d_time (dd) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_dd_dt_ix ON d_time (dd_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_hr_ix ON d_time (hr) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_hr_dt_ix ON d_time (hr_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mi_ix ON d_time (mi) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_qtr_ix ON d_time (qtr) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_qtr_dt_ix ON d_time (qtr_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_iwk_ix ON d_time (iwk) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_iwk_dt_ix ON d_time (iwk_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_day_of_wk_ix ON d_time (day_of_wk) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_day_abbrv_ix ON d_time (day_abbrv) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_day_name_ix ON d_time (day_name) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_weekend_ix ON d_time (weekend) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_holiday_ix ON d_time (holiday) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_morning_ix ON d_time (morning) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_afternoon_ix ON d_time (afternoon) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_evening_ix ON d_time (evening) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_night_ix ON d_time (night) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_worktime_ix ON d_time (worktime) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mi5_ix ON d_time (mi5) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mi5_dt_ix ON d_time (mi5_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mi10_ix ON d_time (mi10) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mi10_dt_ix ON d_time (mi10_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mi15_ix ON d_time (mi15) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mi15_dt_ix ON d_time (mi15_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mi30_ix ON d_time (mi30) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_mi30_dt_ix ON d_time (mi30_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_hr2_ix ON d_time (hr2) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_hr2_dt_ix ON d_time (hr2_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_hr3_ix ON d_time (hr3) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_hr3_dt_ix ON d_time (hr3_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_hr6_ix ON d_time (hr6) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_hr6_dt_ix ON d_time (hr6_dt) TABLESPACE ${INDEX_TABLESPACE};
CREATE ${USE_BITMAP_INDEX} INDEX dt_hr12_ix ON d_time (hr12) TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dt_hr12_dt_ix ON d_time (hr12_dt) TABLESPACE ${INDEX_TABLESPACE};

-- trigger will automatically calc and populate all the supported interval fields from time_id
CREATE OR REPLACE TRIGGER compute_time_dim
    BEFORE INSERT ON d_time
    FOR EACH ROW
    DECLARE
        base_dt DATE;
        beg_dt  DATE;
        miod    INTEGER; -- minute of day
        hrod    INTEGER; -- hour of day
    BEGIN
        -- time basis
        SELECT TRUNC(:new.time_id,'MI') INTO base_dt FROM DUAL;
        SELECT base_dt INTO :new.time_id FROM DUAL;
        SELECT TRUNC(base_dt) INTO beg_dt FROM DUAL; -- begining of day
        SELECT TRUNC( TO_NUMBER(TO_CHAR(base_dt,'SSSSS')) / 60 ) INTO miod FROM DUAL; -- minute of day
        SELECT TO_NUMBER(TO_CHAR(base_dt,'HH24')) INTO hrod FROM DUAL; -- hour of day

        -- years
        SELECT TRUNC(base_dt,'yyyy') INTO :new.yyyy_dt FROM DUAL;
        SELECT EXTRACT(YEAR from base_dt) INTO :new.yyyy FROM DUAL;

        -- months
        SELECT TRUNC(base_dt,'mm') INTO :new.mm_dt FROM DUAL;
        SELECT EXTRACT(MONTH from base_dt) INTO :new.mm FROM DUAL;
        SELECT TO_CHAR(base_dt,'Mon') INTO :new.mon FROM DUAL;
        SELECT TO_CHAR(base_dt,'Month') INTO :new.month FROM DUAL;

        -- days
        SELECT TRUNC(base_dt,'dd') INTO :new.dd_dt FROM DUAL;
        SELECT EXTRACT(DAY from base_dt) INTO :new.dd FROM DUAL;

        -- week days
        SELECT TO_NUMBER(TO_CHAR(base_dt,'D')) INTO :new.day_of_wk FROM DUAL;
        SELECT TO_CHAR(base_dt,'Day') INTO :new.day_name FROM DUAL;
        SELECT SUBSTR(TO_CHAR(base_dt,'Day'),1,3) INTO :new.day_abbrv FROM DUAL;
        SELECT DECODE(TO_NUMBER(TO_CHAR(base_dt,'D')),1,1,7,1,0) INTO :new.weekend FROM DUAL;

        -- hours
        SELECT TRUNC(base_dt,'HH24') INTO :new.hr_dt FROM DUAL;
        SELECT TO_NUMBER(TO_CHAR(base_dt,'HH24')) INTO :new.hr FROM DUAL;
        SELECT DECODE( TRUNC(TO_NUMBER(TO_CHAR(base_dt,'HH24'))/6), 0, 1, 0) INTO :new.night FROM DUAL;
        SELECT DECODE( TRUNC(TO_NUMBER(TO_CHAR(base_dt,'HH24'))/6), 1, 1, 0) INTO :new.morning FROM DUAL;
        SELECT DECODE( TRUNC(TO_NUMBER(TO_CHAR(base_dt,'HH24'))/6), 2, 1, 0) INTO :new.afternoon FROM DUAL;
        SELECT DECODE( TRUNC(TO_NUMBER(TO_CHAR(base_dt,'HH24'))/6), 3, 1, 0) INTO :new.evening FROM DUAL;
        SELECT CASE WHEN TO_NUMBER(TO_CHAR(base_dt,'HH24')) >= 8
                     AND TO_NUMBER(TO_CHAR(base_dt,'HH24')) <= 17
               THEN 1 ELSE 0 END INTO :new.worktime FROM DUAL;
        SELECT TRUNC(hrod/2) INTO :new.hr2 FROM DUAL;
        SELECT TRUNC(beg_dt + (TRUNC(hrod/2)*2/24), 'HH24') INTO :new.hr2_dt FROM DUAL;
        SELECT TRUNC(hrod/3) INTO :new.hr3 FROM DUAL;
        SELECT TRUNC(beg_dt + (TRUNC(hrod/3)*3/24), 'HH24') INTO :new.hr3_dt FROM DUAL;
        SELECT TRUNC(hrod/6) INTO :new.hr6 FROM DUAL;
        SELECT TRUNC(beg_dt + (TRUNC(hrod/6)*6/24), 'HH24') INTO :new.hr6_dt FROM DUAL;
        SELECT TRUNC(hrod/12) INTO :new.hr12 FROM DUAL;
        SELECT TRUNC(beg_dt + (TRUNC(hrod/12)*12/24), 'HH24') INTO :new.hr12_dt FROM DUAL;

        -- minutes
        SELECT TO_NUMBER(TO_CHAR(base_dt,'MI')) INTO :new.mi FROM DUAL;
        SELECT TRUNC(miod/5) INTO :new.mi5 FROM DUAL;
        SELECT TRUNC(beg_dt + (TRUNC(miod/5)*5/(24*60)), 'MI') INTO :new.mi5_dt FROM DUAL;
        SELECT TRUNC(miod/10) INTO :new.mi10 FROM DUAL;
        SELECT TRUNC(beg_dt + (TRUNC(miod/10)*10/(24*60)), 'MI') INTO :new.mi10_dt FROM DUAL;
        SELECT TRUNC(miod/15) INTO :new.mi15 FROM DUAL;
        SELECT TRUNC(beg_dt + (TRUNC(miod/15)*15/(24*60)), 'MI') INTO :new.mi15_dt FROM DUAL;
        SELECT TRUNC(miod/30) INTO :new.mi30 FROM DUAL;
        SELECT TRUNC(beg_dt + (TRUNC(miod/30)*30/(24*60)), 'MI') INTO :new.mi30_dt FROM DUAL;

        -- quarters
        SELECT TRUNC(base_dt,'Q') INTO :new.qtr_dt FROM DUAL;
        SELECT TO_NUMBER(TO_CHAR(base_dt,'Q')) INTO :new.qtr FROM DUAL;

        -- weeks
        SELECT TRUNC(base_dt,'IW') INTO :new.iwk_dt FROM DUAL;
        SELECT TO_NUMBER(TO_CHAR(base_dt,'IW')) INTO :new.iwk FROM DUAL;

        --TODO: holiday needs work
        SELECT 0 INTO :new.holiday FROM DUAL;

    END;
/
GRANT SELECT, UPDATE, INSERT ON d_time TO ${JIFFY_LOADER_USERNAME};
GRANT SELECT ON d_time TO ${JIFFY_READER_USERNAME};
/

-- page dimension
BEGIN EXECUTE IMMEDIATE 'DROP TABLE d_page';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE TABLE d_page (
    page_id     NUMBER          NOT NULL,
    page_name   VARCHAR2(255)   NULL,
    page_group1 VARCHAR2(255)   NULL,
    page_group2 VARCHAR2(255)   NULL,
    CONSTRAINT d_page_pk PRIMARY KEY
    (
        page_id
    ) USING INDEX TABLESPACE ${INDEX_TABLESPACE}
);
CREATE UNIQUE INDEX dp_name_ix
    ON d_page (page_name)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dp_group1_ix
    ON d_page (page_group1)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dp_group2_ix
    ON d_page (page_group2)
    TABLESPACE ${INDEX_TABLESPACE};

CREATE OR REPLACE TRIGGER dp_seq_id
    BEFORE INSERT ON d_page
    FOR EACH ROW
    BEGIN
        IF :new.page_id IS NULL THEN
            SELECT page_id_seq.nextval INTO :new.page_id FROM DUAL;
        END IF;
    END;
/
GRANT SELECT, UPDATE, INSERT ON d_page TO ${JIFFY_LOADER_USERNAME};
GRANT SELECT ON d_page TO ${JIFFY_READER_USERNAME};
/

-- code dimension
BEGIN EXECUTE IMMEDIATE 'DROP TABLE d_code';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE TABLE d_code (
    code_id     NUMBER          NOT NULL,
    code        VARCHAR2(20)    NOT NULL,
    code_group1 VARCHAR2(255)   NULL,
    code_group2 VARCHAR2(255)   NULL,
    CONSTRAINT d_code_pk PRIMARY KEY
    (
        code_id
    ) USING INDEX TABLESPACE ${INDEX_TABLESPACE}
);
CREATE UNIQUE INDEX dc_name_ix
    ON d_code (code)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dc_group1_ix
    ON d_code (code_group1)
    TABLESPACE ${INDEX_TABLESPACE};
CREATE INDEX dc_group2_ix
    ON d_code (code_group2)
    TABLESPACE ${INDEX_TABLESPACE};

CREATE OR REPLACE TRIGGER dc_seq_id
    BEFORE INSERT ON d_code
    FOR EACH ROW
    BEGIN
        IF :new.code_id IS NULL THEN
            SELECT code_id_seq.nextval INTO :new.code_id FROM DUAL;
        END IF;
    END;
/
GRANT SELECT, UPDATE, INSERT ON d_code TO ${JIFFY_LOADER_USERNAME};
GRANT SELECT ON d_code TO ${JIFFY_READER_USERNAME};
/

-- singleton table to store last detail processed
BEGIN EXECUTE IMMEDIATE 'DROP TABLE measurement_last_seq';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE TABLE measurement_last_seq
(
    last_seq    NUMBER
);
INSERT INTO measurement_last_seq (last_seq) VALUES (0);

GRANT SELECT, UPDATE, INSERT ON measurement_last_seq TO ${JIFFY_LOADER_USERNAME};
GRANT SELECT ON measurement_last_seq TO ${JIFFY_READER_USERNAME};
/

-- temporary staging table for fact + dimension consruction
BEGIN EXECUTE IMMEDIATE 'DROP TABLE measurement_facts_stage';
    EXCEPTION WHEN OTHERS THEN NULL; END;
/
CREATE TABLE measurement_facts_stage
(
    d_time_id       DATE    NOT NULL,   -- DATETIME is a natural unique key and easily indexed
    d_code_id       NUMBER  NULL,
    d_code          VARCHAR2(20) NOT NULL,
    d_page_id       NUMBER  NULL,
    d_page          VARCHAR2(255) NULL,
    d_cat1_id       NUMBER  NULL, -- awaiting support for this dimension
    d_cat1          VARCHAR2(255) NULL,
    d_cat2_id       NUMBER  NULL, -- awaiting support for this dimension
    d_cat2          VARCHAR2(255) NULL,
    d_os_id         NUMBER  NULL, -- awaiting support for this dimension
    d_os            VARCHAR2(255) NULL,
    d_browser_id    NUMBER  NULL, -- awaiting support for this dimension
    d_browser       VARCHAR2(255) NULL,
    et_count        NUMBER,
    et_sum          NUMBER,
    et_sum_squares  NUMBER,
    -- et_mean and et_std are functionally derived from sum, count, and sum of squares
    et_min          NUMBER,
    et_max          NUMBER,
    CONSTRAINT measurement_facts_stage_pk PRIMARY KEY
    (
        d_time_id,
        d_code,
        d_page,
        d_cat1,
        d_cat2,
        d_os,
        d_browser
    ) USING INDEX TABLESPACE ${INDEX_TABLESPACE}
);

GRANT SELECT, UPDATE, INSERT ON measurement_facts_stage TO ${JIFFY_LOADER_USERNAME};
GRANT SELECT ON measurement_facts_stage TO ${JIFFY_READER_USERNAME};
/

-- roll-up detailed log along the finiest time interval (1mi)
CREATE OR REPLACE VIEW jiffy_sum_detail_fine AS
SELECT
    TRUNC(server_time,'MI') stime
  , measurement_code
  , page_name
  , user_cat1
  , user_cat2
-- TODO: break user agent into OS/BROWSER dimension
--  , user_agent
  , NULL as os
  , NULL as browser
  , COUNT(elapsed_time) et_count
  , SUM(elapsed_time) et_sum
  , SUM(elapsed_time*elapsed_time) et_sum_squares
  , MIN(elapsed_time) et_min
  , MAX(elapsed_time) et_max
FROM measurement_view
GROUP BY
    TRUNC(server_time,'MI')
  , measurement_code
  , page_name
  , user_cat1
  , user_cat2
--  , user_agent
;

GRANT SELECT, UPDATE, INSERT ON jiffy_sum_detail_fine TO ${JIFFY_LOADER_USERNAME};
GRANT SELECT ON jiffy_sum_detail_fine TO ${JIFFY_READER_USERNAME};
/

" > $OUT1

echo "
CONNECT ${JIFFY_USERNAME}/${JIFFY_PASS}@${CONNECTSTRING};

create or replace synonym MEASUREMENT_PART for JIFFY.MEASUREMENT_20080601;

CREATE OR REPLACE PACKAGE roll_up
IS
    FUNCTION next_minute(dt IN d_time.time_id%TYPE) RETURN d_time.time_id%TYPE;
    PROCEDURE extend_time_dim(beg_in IN d_time.time_id%TYPE, end_in IN d_time.time_id%TYPE);
    PROCEDURE roll_up_partition(part_in IN VARCHAR2, beg_in IN NUMBER, end_in IN NUMBER);
    PROCEDURE roll_up_range(beg_in IN NUMBER, end_in IN NUMBER);
    PROCEDURE roll_up_new;
END roll_up;
/
show errors

CREATE OR REPLACE PACKAGE BODY roll_up
IS
    HOURS_PER_DAY   INTEGER := 24;
    MINUTES_PER_DAY INTEGER := (HOURS_PER_DAY * 60);
    SECS_PER_DAY    INTEGER := (MINUTES_PER_DAY * 60);

    -- keeps size of each range roll-up to easily manageable chunks
    MAX_DETAILS_PER_ROLLUP INTEGER := 1000000;

    FUNCTION next_minute(dt IN d_time.time_id%TYPE) RETURN d_time.time_id%TYPE
    IS
        next_mi d_time.time_id%TYPE;
    BEGIN
        select round(dt+1/MINUTES_PER_DAY,'MI') into next_mi from dual;
        RETURN next_mi;
    END next_minute;

    PROCEDURE extend_time_dim(beg_in IN d_time.time_id%TYPE, end_in IN d_time.time_id%TYPE)
    IS
        dt      d_time.time_id%TYPE;
        min_dt  d_time.time_id%TYPE;
        max_dt  d_time.time_id%TYPE;
        beg_dt  d_time.time_id%TYPE;
        end_dt  d_time.time_id%TYPE;
    BEGIN
        -- fix range bounds
        select max(time_id) into max_dt from d_time;
		if max_dt is null then
			-- init time dimension to cover this year
			select trunc(sysdate,'YYYY') into beg_dt from dual;
			select trunc(beg_dt+366,'YYYY') into end_dt from dual;
		else
			select min(time_id) into min_dt from d_time;
	        select TRUNC(beg_in,'MI') into beg_dt from dual;
	        select TRUNC(end_in,'MI') into end_dt from dual;
			if beg_dt is null or (min_dt <= beg_dt and beg_dt <= max_dt) then
				beg_dt := next_minute(max_dt);
			end if;
			if beg_dt < min_dt then
				end_dt := min_dt;	-- filling prior time range, bring forward to existing
			end if;
	        if end_dt is null then
	            -- default will extend to end of next day
	            select trunc(beg_dt+1.99,'DD') into end_dt from dual;
	        end if;
		end if;

        -- loop, inserting d_time records for minute intervals
        dt := beg_dt;
        while dt < end_dt
        loop
            insert into d_time(time_id) values (dt);
            dt := next_minute(dt);
        end loop;
    END extend_time_dim;

    PROCEDURE roll_up_partition(part_in IN VARCHAR2, beg_in IN NUMBER, end_in IN NUMBER)
    IS
		tstr	VARCHAR2(2000);
        max_dt  d_time.time_id%TYPE;
    BEGIN
        --dbms_output.put_line('part_in=' || to_char(part_in));
		-- bind synonym to this partition
		tstr := 'create or replace synonym MEASUREMENT_PART for JIFFY.MEASUREMENT_' || part_in;
		execute immediate tstr;
		-- empty the facts stage
		execute immediate 'truncate table measurement_facts_stage';
		-- roll up to stage
		insert into measurement_facts_stage (
			d_time_id
		  , d_code
		  , d_page
		  , d_browser
		  , d_os
		  , d_cat1
		  , d_cat2
		  , et_count
		  , et_sum
		  , et_sum_squares
		  , et_min
		  , et_max
		)
			select
				trunc(server_time,'MI') stime
			  , measurement_code
			  , page_name
			  , browser
			  , os
			  , user_cat1
			  , user_cat2
			  , count(elapsed_time) et_count
			  , sum(elapsed_time) et_sum
			  , sum(elapsed_time * elapsed_time) et_sum_squares
			  , min(elapsed_time) et_min
			  , max(elapsed_time) et_max
			from MEASUREMENT_PART o
			where exists (  -- select only affected roll ups
				select null
				from MEASUREMENT_PART i
				where beg_in <= i.seq and i.seq <= end_in
				and trunc(i.server_time,'MI') = trunc(o.server_time,'MI')
				and i.measurement_code = o.measurement_code
				and i.page_name = o.page_name
				--TODO: add other dims as supported
			)
			group by
				trunc(server_time,'MI')
			  , measurement_code
			  , page_name
			  , browser
			  , os
			  , user_cat1
			  , user_cat2
		;

		-- extend time dimension if necc
		select max(d_time_id) into max_dt from measurement_facts_stage;
		if max_dt is null then
			return;	-- nothing to do
		end if;
		extend_time_dim(NULL, next_minute(max_dt) );

		-- extend code dim
		insert into d_code (code)
			select DISTINCT d_code
			from measurement_facts_stage mfs
			where not exists (
				select null
				from d_code d
				where d.code = mfs.d_code
			)
		;

		-- extend page dim
		insert into d_page (page_name)
			select DISTINCT d_page
			from measurement_facts_stage mfs
			where not exists (
				select null
				from d_page d
				where d.page_name = mfs.d_page
			)
		;

		-- map dim ids
		update measurement_facts_stage mfs set
			d_code_id = (select d.code_id from d_code d where d.code = mfs.d_code)
		  , d_page_id = (select d.page_id from d_page d where d.page_name = mfs.d_page)
		;

		-- update facts table
		-- TODO: figure out if merge is available or update/insert is better than delete/insert
		delete from measurement_facts mf
		where exists (
			select null
			from measurement_facts_stage mfs
			where
				mf.d_time_id = mfs.d_time_id
			and mf.d_code_id = mfs.d_code_id
			and mf.d_page_id = mfs.d_page_id
			and mf.d_browser_id = mfs.d_browser_id
			and mf.d_os_id = mfs.d_os_id
			and mf.d_cat1_id = mfs.d_cat1_id
			and mf.d_cat2_id = mfs.d_cat2_id
		);
		insert into measurement_facts (
			d_time_id
		  , d_code_id
		  , d_page_id
		  , d_browser_id
		  , d_os_id
		  , d_cat1_id
		  , d_cat2_id
		  , et_count
		  , et_sum
		  , et_sum_squares
		  , et_min
		  , et_max
		)
			select
				d_time_id
			  , d_code_id
			  , d_page_id
			  , d_browser_id
			  , d_os_id
			  , d_cat1_id
			  , d_cat2_id
			  , et_count
			  , et_sum
			  , et_sum_squares
			  , et_min
			  , et_max
			from measurement_facts_stage
		;
	END roll_up_partition;

    PROCEDURE roll_up_range(beg_in IN NUMBER, end_in IN NUMBER)
    IS
    BEGIN
        --dbms_output.put_line('beg=' || to_char(beg_in));
	    for rec in (
			select trunc(server_time,'DD') part
	        from measurement_view
			where beg_in <= seq and seq <= end_in
			group by trunc(server_time,'DD')
			order by trunc(server_time,'DD')
		)
	    loop
			roll_up_partition(TO_CHAR(rec.part,'YYYYMMDD'), beg_in, end_in);
	    end loop;
    END roll_up_range;

    PROCEDURE roll_up_new
    IS
        last    NUMBER;
        high    NUMBER;
    BEGIN
        select last_seq into last from measurement_last_seq;
        select max(seq) into high from measurement_view where seq >= last;
		if high - last > MAX_DETAILS_PER_ROLLUP then
			high := last + MAX_DETAILS_PER_ROLLUP;
		end if;
        roll_up_range(last,high);
        update measurement_last_seq set last_seq = high+1;
        commit;
    END roll_up_new;

END roll_up;
/
show errors
" > $OUT2

echo ""
echo "****************************"
echo "* Generation Done"
echo "****************************"
echo ""
echo "Run the following scripts from your SQL prompt"
echo "  $ sqlplus /nolog @$OUT1"
echo "  $ sqlplus /nolog @$OUT2"


<reponame>hyungman/SpRay
#!/bin/bash

# set the following three variables
# embree_library_path=not required on macOS
intel_tbb_library_path=
spray_home_path=
spray_bin_path=

export DYLD_LIBRARY_PATH=$intel_tbb_library_path:$DYLD_LIBRARY_PATH
export SPRAY_HOME_PATH=$spray_home_path
export SPRAY_BIN_PATH=$spray_bin_path


<gh_stars>1-10
#!/bin/sh
#
# Copyright 2016 caicloud authors. All rights reserved.

set -e
set -u
set -o pipefail

source "$(dirname "${BASH_SOURCE}")/lib/common.sh"
cd ${CYCLONE_ROOT}

cyclone_src="/go/src/github.com/caicloud/cyclone"

BUILD_IN="cargo.caicloud.io/caicloud/golang-docker:1.7-17.03"
echo "build in ${BUILD_IN}"
docker run --rm \
  -v ${CYCLONE_ROOT}:${cyclone_src} \
  -e GOPATH=/go \
  -w ${cyclone_src} \
  ${BUILD_IN} go test -cover $(go list ./... | grep -v '/vendor/' | grep -v '/tests/')

BUILD_IN="cargo.caicloud.io/caicloud/golang-docker:1.8-17.03"
echo "build in ${BUILD_IN}"
docker run --rm \
  -v ${CYCLONE_ROOT}:${cyclone_src} \
  -e GOPATH=/go \
  -w ${cyclone_src} \
  ${BUILD_IN} go test -cover $(go list ./... | grep -v '/vendor/' | grep -v '/tests/')


<reponame>rmetcalf9/dockJob<filename>app/deleteTest.sh
#!/bin/bash
echo "Runs delete job test mutiple times to catch intermatiant failure"

while [ 1 = 1 ]
do
  sudo nosetests --rednose ./test/test_jobsDataAPI.py:test_jobsData.test_deleteJobRemovedExecutionLogs
  echo "complete"
  # need to sleep to give ctl+c a chance to work
  sleep 1
done


<gh_stars>1-10
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.

zooKList=$1
if [ "$zooKList" == "" ]
then
  echo Usage $0 <zookeeper-host:2181>
  exit 1
fi

ephemeral=$(date +%Y%m%d-%H%M%S)
allTopicsDetails="AllTopicsDetails.${ephemeral}"
echo "All topics details will be sent to file: $allTopicsDetails"
kafka-topics.sh --describe --zookeeper ${zooKList} >> $allTopicsDetails

echo "Details of output file $allTopicsDetails:"
file $allTopicsDetails
wc -l $allTopicsDetails


<filename>install/installopenni.sh
#!/bin/bash

echo "Installing openni"
printf '\n\n' | sudo apt-add-repository ppa:deb-rob/ros-trusty
sudo apt-get --yes --force-yes update
sudo apt-get --yes --force-yes install libopenni2-dev
echo "Done installing openni"


#!/system/bin/sh

#Copyright (c) 2015 Lenovo Co. Ltd
#Authors: <EMAIL>

umask 022

#LOGDIR=$(getprop persist.sys.lenovo.log.path)

CFGFILE=$(getprop persist.sys.lenovo.log.qxdmcfg)

LOGDISK=$(getprop persist.sys.lenovo.log.disk)
LOGFOLDER=$(getprop persist.sys.lenovo.log.folder)

LOGDIR=$LOGDISK"/log/"$LOGFOLDER

chmod 777 $CFGFILE

if [ ! -s $CFGFILE ]; then
	setprop persist.sys.lenovo.log.qxdm FALSE
	setprop persist.sys.lenovo.log.qxdmcfg " "
else
    #use this to flag the qxdm log has been opened in this boot
    setprop  sys.lenovo.log.qxdm "opened"
	#kill the diag_mdlog process at first
	/system/bin/diag_mdlog -k
	# -s set the single log size in MB , -n set the number of file saved
	/system/bin/diag_mdlog -s 512 -n 6 -f $CFGFILE -o $LOGDIR
fi


#!/bin/sh

if [ $# -ne 6 ]; then
    echo "usage <dir> <package-name> <package-ver> <package-rev> <author-name> <author-email>"
    exit 1
fi

DIR="${1}"
PN="${2}"
PV="${3}"
PR="${4}"
AUTHOR_NAME="${5}"
AUTHOR_EMAIL="${6}"

set -e

cd "${DIR}"
mkdir -p DEBIAN
echo "Package: ${PN}" > DEBIAN/control
echo "Version: ${PV}-${PR}" >> DEBIAN/control
echo "Section: base" >> DEBIAN/control
echo "Priority: optional" >> DEBIAN/control
echo "Architecture: `dpkg --print-architecture`" >> DEBIAN/control
#RUN echo "Depends: " >> DEBIAN/control
echo "Maintainer: ${AUTHOR_NAME} <${AUTHOR_EMAIL}>" >> DEBIAN/control
echo "Description: ${PN}" >> DEBIAN/control
echo " ${PN}" >> DEBIAN/control
cd "${OLDPWD}"
dpkg-deb --build "${DIR}"


#!/bin/bash

if test $# -lt 1; then
   echo "Usage: ./upload_ee.sh GCS_IMAGE_DIR"
   echo "e.g:   ./upload_ee.sh gs://cloud-training-demos/landsat/output2015"
   exit -1
fi

INDIR=$1
GCS_IMAGES=$(gsutil ls -r $INDIR | grep TIF)
EEUSER=vlakshmanan

collection=users/$EEUSER/reunionvideo
earthengine create collection $collection

for GCS_IMAGE in $GCS_IMAGES; do
   BASE=$(echo $GCS_IMAGE | sed 's/gs:..//g' | sed 's/.TIF//g' | sed 's/\//_/g')
   assetid="$collection/$BASE"
   echo "$GCS_IMAGE --> $assetid"
   earthengine upload image --nodata_value 255 --asset_id $assetid $GCS_IMAGE
done

echo "Use this script in earthengine to export a video:

var palette = ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',
               '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',
               '012E01', '011D01', '011301'];
var vizParams = {min: 0, max: 100, palette: palette};
var polygon = ee.Geometry.Rectangle([55.1, -20.85, 55.9, -21.4]);

var collection = ee.ImageCollection('users/$EEUSER/reunionvideo');

var withMonths = collection.map(function(image) {
  var groups = image.id().match('LC8......(....)(...)....._ndvi');
  var year = ee.Number.parse(groups.get(1));
  var doy = ee.Number.parse(groups.get(2));
  var date = ee.Date.fromYMD(year, 1, 1).advance(doy.subtract(1), 'day');
  return image.set('month', date.get('month'));
});

var monthlyImages = ee.List.sequence(1, 12).map(function(month) {
  return withMonths.filter(ee.Filter.equals('month', month))
    .max().visualize(vizParams);
});

Export.video.toDrive({
  collection: ee.ImageCollection(monthlyImages),
  description: 'reunionee',
  dimensions: 720,
  framesPerSecond: 12,
  region: polygon,
});

"


#!/bin/bash

dirname="msp430-gcc-7.3.1.24-source-full"
buildscript="README-build.sh"

# Download the missing MSP430-GCC sources from Texas Instruments
echo "Downloading and extracting GCC sources"
./download-sources.sh

# Build MSP430-GCC
cd $dirname
if [ ! -f $buildscript ]; then
    echo "Build script: $buildscript not found"
    exit 1
fi

# Make a "fast" version of the build script (make -j)
echo "Creating fast version of the build script"
sed "s/make$/make -j$(nproc)/g" ./$buildscript > ./fast-$buildscript

# Make build script executable
echo "Running build script"
chmod +x fast-$buildscript
./fast-$buildscript


<reponame>VoiceZen/DeepSpeech
#! /usr/bin/env bash

cd ../.. > /dev/null

# cd models/lm > /dev/null
# sh download_lm_en.sh
if [ $? -ne 0 ]; then
    exit 1
fi
# cd - > /dev/null

# infer
CUDA_VISIBLE_DEVICES=0,1 \
python -u greed_infer.py \
--num_samples=32 \
--trainer_count=2 \
--num_conv_layers=2 \
--num_rnn_layers=3 \
--rnn_layer_size=1024 \
--use_gru=True \
--use_gpu=False \
--share_rnn_weights=True \
--infer_manifest='data/librispeech/manifest.test-clean' \
--mean_std_path='data/librispeech/mean_std.npz' \
--vocab_path='data/librispeech/vocab.txt' \
--model_path='checkpoints/libri/step_final' \
--lang_model_path='models/lm/common_crawl_00.prune01111.trie.klm' \
--decoding_method='ctc_beam_search' \
--error_rate_type='wer' \
--specgram_type='linear'

if [ $? -ne 0 ]; then
    echo "Failed in inference!"
    exit 1
fi

exit 0


#!/bin/bash

nflag=false

usage () { echo "
    -h -- Opens up this help message
    -c -- EKS cluster name where the EFS will be configured
    -n -- Application namespace
"; }
options=':c:n:h'
while getopts $options option
do
    case "$option" in
        c  ) K8S_CLUSTER_NAME=${OPTARG-$K8S_CLUSTER_NAME};;
        n  ) nflag=true; APP_NAMESPACE=${OPTARG-$APP_NAMESPACE};;
        h  ) usage; exit;;
        \? ) echo "Unknown option: -$OPTARG" >&2; exit 1;;
        :  ) echo "Missing option argument for -$OPTARG" >&2; exit 1;;
        *  ) echo "Unimplemented option: -$OPTARG" >&2; exit 1;;
    esac
done

#######################################
# Treating parameters
missing_parameters=false

K8S_CLUSTER_NAME="$(sed -e 's/[[:space:]]*$//' <<<${K8S_CLUSTER_NAME})"
if [ -z "${K8S_CLUSTER_NAME// }" ]
then
    echo "-c nor K8S_CLUSTER_NAME env variable specified. Please inform the EKS cluster name..." >&2
    missing_parameters=true
fi

APP_NAMESPACE="$(sed -e 's/[[:space:]]*$//' <<<${APP_NAMESPACE})"
if ! $nflag
then
    echo "-n nor APP_NAMESPACE env variable specified, using poc-efs-eks-fargate for k8s application namespace..." >&2
    APP_NAMESPACE="poc-efs-eks-fargate"
fi

if $missing_parameters
then
    exit 99
fi

# Create a Kubernetes namespace for application workloads
kubectl create namespace ${APP_NAMESPACE}

# Create a custom Fargate Profile linked to created namespace
eksctl create fargateprofile \
                --namespace "${APP_NAMESPACE}" \
                --cluster "${K8S_CLUSTER_NAME}" \
                --name "fp-${APP_NAMESPACE}"


<gh_stars>0
#!/usr/bin/env bash
export PYTHONPATH="$(pwd)"


<filename>modules/platform/admin-jest.sh
#!/usr/bin/env bash

checkParameter

cd "/var/www/html/${SHOPWARE_PROJECT}" || exit 1
export PROJECT_ROOT="/var/www/html/${SHOPWARE_PROJECT}"
export ENV_FILE="${PROJECT_ROOT}/.env"
PLATFORM_PATH=$(platform_component Administration)
export ADMIN_PATH="/var/www/html/sw6/${PLATFORM_PATH}Resources/app/administration/"

npm run --prefix "$ADMIN_PATH" unit-watch


#!/bin/bash

source scripts/array_to_string_functions.sh

COMPILE_JOB_ID=`sbatch --parsable scripts/make_hip.sh --exclude=n[001-004,017-018]`

SRCDIR=`pwd`

OPTIMIZATION_TIME=0.1

if false; then
echo "this part not executed"
# ... Code I want to skip here ...
fi

######################## REAL TRANSFER #################################
EXPERIMENT_FOLDER_NAME="src/experiments/real/results/transferability/controllers_trained_on_random_instances"
COMPUTE_RESPONSE="true"
SCORE_PATH="src/experiments/real/results/transferability/transfer_score.txt"
RESPONSE_PATH="src/experiments/real/results/transferability/transfer_response.txt"
TMP_RES_PATH="${SRCDIR}/tmp/${EXPERIMENT_FOLDER_NAME}"
N_REPS=1
N_EVALS=1000
MAX_TRAIN_ITERATIONS=200

standard_NEAT_POPSIZE=128
standard_NLO=20
standard_DIM=10
standard_SOLVER_POPSIZE=20
standard_MAX_SOLVER_FE=10000
########################################################################

###########################################################################################################################
EXP_NAME="NLO"
NEAT_POPSIZE_ARRAY=()
CONTROLLER_NAME_PREFIX_ARRAY=()
EXPERIMENT_FOLDER_NAME_ARRAY=()
SEED_ARRAY=()
PROBLEM_NLO_ARRAY=()
PROBLEM_DIM_ARRAY=()
SOLVER_POPSIZE_ARRAY=()
MAX_SOLVER_FE_ARRAY=()

i=-1
for NLO_train in 1 4 16 64; do
    i=$((i+1))

    NEAT_POPSIZE_ARRAY+=("${standard_NEAT_POPSIZE}")
    CONTROLLER_NAME_PREFIX_ARRAY+=("NLO_${NLO_train}")
    EXPERIMENT_FOLDER_NAME_ARRAY+=("${EXPERIMENT_FOLDER_NAME}")
    SEED_ARRAY+=("${i}")
    PROBLEM_NLO_ARRAY+=("${NLO_train}")
    PROBLEM_DIM_ARRAY+=("${standard_DIM}")
    SOLVER_POPSIZE_ARRAY+=("${standard_SOLVER_POPSIZE}")
    MAX_SOLVER_FE_ARRAY+=("${standard_MAX_SOLVER_FE}")
done

NEAT_POPSIZE_ARRAY=$(to_list "${NEAT_POPSIZE_ARRAY[@]}")
CONTROLLER_NAME_PREFIX_ARRAY=$(to_list "${CONTROLLER_NAME_PREFIX_ARRAY[@]}")
EXPERIMENT_FOLDER_NAME_ARRAY=$(to_list "${EXPERIMENT_FOLDER_NAME_ARRAY[@]}")
SEED_ARRAY=$(to_list "${SEED_ARRAY[@]}")
PROBLEM_NLO_ARRAY=$(to_list "${PROBLEM_NLO_ARRAY[@]}")
PROBLEM_DIM_ARRAY=$(to_list "${PROBLEM_DIM_ARRAY[@]}")
SOLVER_POPSIZE_ARRAY=$(to_list "${SOLVER_POPSIZE_ARRAY[@]}")
MAX_SOLVER_FE_ARRAY=$(to_list "${MAX_SOLVER_FE_ARRAY[@]}")

TRAINING_JOB_ID=`sbatch --parsable --dependency=afterok:${COMPILE_JOB_ID} --export=MAX_TRAIN_ITERATIONS=${MAX_TRAIN_ITERATIONS},NEAT_POPSIZE_ARRAY=$NEAT_POPSIZE_ARRAY,CONTROLLER_NAME_PREFIX_ARRAY=$CONTROLLER_NAME_PREFIX_ARRAY,EXPERIMENT_FOLDER_NAME_ARRAY=$EXPERIMENT_FOLDER_NAME_ARRAY,SEED_ARRAY=$SEED_ARRAY,PROBLEM_NLO_ARRAY=$PROBLEM_NLO_ARRAY,PROBLEM_DIM_ARRAY=$PROBLEM_DIM_ARRAY,SOLVER_POPSIZE_ARRAY=$SOLVER_POPSIZE_ARRAY,MAX_SOLVER_FE_ARRAY=$MAX_SOLVER_FE_ARRAY --array=0-$i src/experiments/real/scripts/hip_train_array_random_problem.sl`

TESTING_JOB_ID=""

NEAT_POPSIZE_ARRAY=()
CONTROLLER_NAME_PREFIX_ARRAY=()
EXPERIMENT_FOLDER_NAME_ARRAY=()
SEED_ARRAY=()
PROBLEM_NLO_ARRAY=()
PROBLEM_DIM_ARRAY=()
SOLVER_POPSIZE_ARRAY=()
MAX_SOLVER_FE_ARRAY=()
i=-1
for NLO_train in 1 4 16 64; do
    for NLO_test in 1 4 16 64; do
        i=$((i+1))

        NEAT_POPSIZE_ARRAY+=("${standard_NEAT_POPSIZE}")
        CONTROLLER_NAME_PREFIX_ARRAY+=("NLO_${NLO_train}")
        EXPERIMENT_FOLDER_NAME_ARRAY+=("${EXPERIMENT_FOLDER_NAME}")
        SEED_ARRAY+=("${i}")
        PROBLEM_NLO_ARRAY+=("${NLO_test}")
        PROBLEM_DIM_ARRAY+=("${standard_DIM}")
        SOLVER_POPSIZE_ARRAY+=("${standard_SOLVER_POPSIZE}")
        MAX_SOLVER_FE_ARRAY+=("${standard_MAX_SOLVER_FE}")
    done
done

NEAT_POPSIZE_ARRAY=$(to_list "${NEAT_POPSIZE_ARRAY[@]}")
CONTROLLER_NAME_PREFIX_ARRAY=$(to_list "${CONTROLLER_NAME_PREFIX_ARRAY[@]}")
EXPERIMENT_FOLDER_NAME_ARRAY=$(to_list "${EXPERIMENT_FOLDER_NAME_ARRAY[@]}")
SEED_ARRAY=$(to_list "${SEED_ARRAY[@]}")
PROBLEM_NLO_ARRAY=$(to_list "${PROBLEM_NLO_ARRAY[@]}")
PROBLEM_DIM_ARRAY=$(to_list "${PROBLEM_DIM_ARRAY[@]}")
SOLVER_POPSIZE_ARRAY=$(to_list "${SOLVER_POPSIZE_ARRAY[@]}")
MAX_SOLVER_FE_ARRAY=$(to_list "${MAX_SOLVER_FE_ARRAY[@]}")

TESTING_JOB_ID=`sbatch --parsable --dependency=afterok:${TRAINING_JOB_ID} --export=EXPERIMENT_FOLDER_NAME=${EXPEIMENT_FOLDER_NAME},COMPUTE_RESPONSE=${COMPUTE_RESPONSE},SCORE_PATH=${SCORE_PATH},RESPONSE_PATH=${RESPONSE_PATH},TMP_RES_PATH=${TMP_RES_PATH},N_REPS=${N_REPS},N_EVALS=${N_EVALS},EXP_NAME=${EXP_NAME},NEAT_POPSIZE_ARRAY=$NEAT_POPSIZE_ARRAY,CONTROLLER_NAME_PREFIX_ARRAY=$CONTROLLER_NAME_PREFIX_ARRAY,EXPERIMENT_FOLDER_NAME_ARRAY=$EXPERIMENT_FOLDER_NAME_ARRAY,SEED_ARRAY=$SEED_ARRAY,PROBLEM_NLO_ARRAY=$PROBLEM_NLO_ARRAY,PROBLEM_DIM_ARRAY=$PROBLEM_DIM_ARRAY,SOLVER_POPSIZE_ARRAY=$SOLVER_POPSIZE_ARRAY,MAX_SOLVER_FE_ARRAY=$MAX_SOLVER_FE_ARRAY --array=0-$i src/experiments/real/scripts/hip_test_array.sl`

sbatch --dependency=afterok:$TESTING_JOB_ID --export=SCORE_PATH=${SCORE_PATH},RESPONSE_PATH=${RESPONSE_PATH},COMPUTE_RESPONSE=${COMPUTE_RESPONSE},TMP_RES_PATH=${TMP_RES_PATH} scripts/cat_result_files_to_exp_folder.sh

###########################################################################################################################

EXP_NAME="DIM"
NEAT_POPSIZE_ARRAY=()
CONTROLLER_NAME_PREFIX_ARRAY=()
EXPERIMENT_FOLDER_NAME_ARRAY=()
SEED_ARRAY=()
PROBLEM_NLO_ARRAY=()
PROBLEM_DIM_ARRAY=()
SOLVER_POPSIZE_ARRAY=()
MAX_SOLVER_FE_ARRAY=()

i=-1
for DIM_train in 2 10 50; do
    i=$((i+1))

    NEAT_POPSIZE_ARRAY+=("${standard_NEAT_POPSIZE}")
    CONTROLLER_NAME_PREFIX_ARRAY+=("DIM_${DIM_train}")
    EXPERIMENT_FOLDER_NAME_ARRAY+=("${EXPERIMENT_FOLDER_NAME}")
    SEED_ARRAY+=("${i}")
    PROBLEM_NLO_ARRAY+=("${standard_NLO}")
    PROBLEM_DIM_ARRAY+=("${DIM_train}")
    SOLVER_POPSIZE_ARRAY+=("${standard_SOLVER_POPSIZE}")
    MAX_SOLVER_FE_ARRAY+=("${standard_MAX_SOLVER_FE}")
done

NEAT_POPSIZE_ARRAY=$(to_list "${NEAT_POPSIZE_ARRAY[@]}")
CONTROLLER_NAME_PREFIX_ARRAY=$(to_list "${CONTROLLER_NAME_PREFIX_ARRAY[@]}")
EXPERIMENT_FOLDER_NAME_ARRAY=$(to_list "${EXPERIMENT_FOLDER_NAME_ARRAY[@]}")
SEED_ARRAY=$(to_list "${SEED_ARRAY[@]}")
PROBLEM_NLO_ARRAY=$(to_list "${PROBLEM_NLO_ARRAY[@]}")
PROBLEM_DIM_ARRAY=$(to_list "${PROBLEM_DIM_ARRAY[@]}")
SOLVER_POPSIZE_ARRAY=$(to_list "${SOLVER_POPSIZE_ARRAY[@]}")
MAX_SOLVER_FE_ARRAY=$(to_list "${MAX_SOLVER_FE_ARRAY[@]}")

TRAINING_JOB_ID=`sbatch --parsable --dependency=afterok:${COMPILE_JOB_ID} --export=MAX_TRAIN_ITERATIONS=${MAX_TRAIN_ITERATIONS},NEAT_POPSIZE_ARRAY=$NEAT_POPSIZE_ARRAY,CONTROLLER_NAME_PREFIX_ARRAY=$CONTROLLER_NAME_PREFIX_ARRAY,EXPERIMENT_FOLDER_NAME_ARRAY=$EXPERIMENT_FOLDER_NAME_ARRAY,SEED_ARRAY=$SEED_ARRAY,PROBLEM_NLO_ARRAY=$PROBLEM_NLO_ARRAY,PROBLEM_DIM_ARRAY=$PROBLEM_DIM_ARRAY,SOLVER_POPSIZE_ARRAY=$SOLVER_POPSIZE_ARRAY,MAX_SOLVER_FE_ARRAY=$MAX_SOLVER_FE_ARRAY --array=0-$i src/experiments/real/scripts/hip_train_array_random_problem.sl`

TESTING_JOB_ID=""

NEAT_POPSIZE_ARRAY=()
CONTROLLER_NAME_PREFIX_ARRAY=()
EXPERIMENT_FOLDER_NAME_ARRAY=()
SEED_ARRAY=()
PROBLEM_NLO_ARRAY=()
PROBLEM_DIM_ARRAY=()
SOLVER_POPSIZE_ARRAY=()
MAX_SOLVER_FE_ARRAY=()
i=-1
for DIM_train in 1 8 64; do
    for DIM_test in 1 8 64; do
        i=$((i+1))

        NEAT_POPSIZE_ARRAY+=("${standard_NEAT_POPSIZE}")
        CONTROLLER_NAME_PREFIX_ARRAY+=("DIM_${DIM_train}")
        EXPERIMENT_FOLDER_NAME_ARRAY+=("${EXPERIMENT_FOLDER_NAME}")
        SEED_ARRAY+=("${i}")
        PROBLEM_NLO_ARRAY+=("${standard_NLO}")
        PROBLEM_DIM_ARRAY+=("${DIM_test}")
        SOLVER_POPSIZE_ARRAY+=("${standard_SOLVER_POPSIZE}")
        MAX_SOLVER_FE_ARRAY+=("${standard_MAX_SOLVER_FE}")
    done
done

NEAT_POPSIZE_ARRAY=$(to_list "${NEAT_POPSIZE_ARRAY[@]}")
CONTROLLER_NAME_PREFIX_ARRAY=$(to_list "${CONTROLLER_NAME_PREFIX_ARRAY[@]}")
EXPERIMENT_FOLDER_NAME_ARRAY=$(to_list "${EXPERIMENT_FOLDER_NAME_ARRAY[@]}")
SEED_ARRAY=$(to_list "${SEED_ARRAY[@]}")
PROBLEM_NLO_ARRAY=$(to_list "${PROBLEM_NLO_ARRAY[@]}")
PROBLEM_DIM_ARRAY=$(to_list "${PROBLEM_DIM_ARRAY[@]}")
SOLVER_POPSIZE_ARRAY=$(to_list "${SOLVER_POPSIZE_ARRAY[@]}")
MAX_SOLVER_FE_ARRAY=$(to_list "${MAX_SOLVER_FE_ARRAY[@]}")

TESTING_JOB_ID=`sbatch --parsable --dependency=afterok:${TRAINING_JOB_ID} --export=EXPERIMENT_FOLDER_NAME=${EXPEIMENT_FOLDER_NAME},COMPUTE_RESPONSE=${COMPUTE_RESPONSE},SCORE_PATH=${SCORE_PATH},RESPONSE_PATH=${RESPONSE_PATH},TMP_RES_PATH=${TMP_RES_PATH},N_REPS=${N_REPS},N_EVALS=${N_EVALS},EXP_NAME=${EXP_NAME},NEAT_POPSIZE_ARRAY=$NEAT_POPSIZE_ARRAY,CONTROLLER_NAME_PREFIX_ARRAY=$CONTROLLER_NAME_PREFIX_ARRAY,EXPERIMENT_FOLDER_NAME_ARRAY=$EXPERIMENT_FOLDER_NAME_ARRAY,SEED_ARRAY=$SEED_ARRAY,PROBLEM_NLO_ARRAY=$PROBLEM_NLO_ARRAY,PROBLEM_DIM_ARRAY=$PROBLEM_DIM_ARRAY,SOLVER_POPSIZE_ARRAY=$SOLVER_POPSIZE_ARRAY,MAX_SOLVER_FE_ARRAY=$MAX_SOLVER_FE_ARRAY --array=0-$i src/experiments/real/scripts/hip_test_array.sl`

sbatch --dependency=afterok:$TESTING_JOB_ID --export=SCORE_PATH=${SCORE_PATH},RESPONSE_PATH=${RESPONSE_PATH},COMPUTE_RESPONSE=${COMPUTE_RESPONSE},TMP_RES_PATH=${TMP_RES_PATH} scripts/cat_result_files_to_exp_folder.sh

###########################################################################################################################

EXP_NAME="POPSIZE"
NEAT_POPSIZE_ARRAY=()
CONTROLLER_NAME_PREFIX_ARRAY=()
EXPERIMENT_FOLDER_NAME_ARRAY=()
SEED_ARRAY=()
PROBLEM_NLO_ARRAY=()
PROBLEM_DIM_ARRAY=()
SOLVER_POPSIZE_ARRAY=()
MAX_SOLVER_FE_ARRAY=()

i=-1
for SOLVER_POPSIZE_train in 10 40 160; do
    i=$((i+1))

    NEAT_POPSIZE_ARRAY+=("${standard_NEAT_POPSIZE}")
    CONTROLLER_NAME_PREFIX_ARRAY+=("POPSIZE_${SOLVER_POPSIZE_train}")
    EXPERIMENT_FOLDER_NAME_ARRAY+=("${EXPERIMENT_FOLDER_NAME}")
    SEED_ARRAY+=("${i}")
    PROBLEM_NLO_ARRAY+=("${standard_NLO}")
    PROBLEM_DIM_ARRAY+=("${standard_DIM}")
    SOLVER_POPSIZE_ARRAY+=("${SOLVER_POPSIZE_train}")
    MAX_SOLVER_FE_ARRAY+=("${standard_MAX_SOLVER_FE}")
done

NEAT_POPSIZE_ARRAY=$(to_list "${NEAT_POPSIZE_ARRAY[@]}")
CONTROLLER_NAME_PREFIX_ARRAY=$(to_list "${CONTROLLER_NAME_PREFIX_ARRAY[@]}")
EXPERIMENT_FOLDER_NAME_ARRAY=$(to_list "${EXPERIMENT_FOLDER_NAME_ARRAY[@]}")
SEED_ARRAY=$(to_list "${SEED_ARRAY[@]}")
PROBLEM_NLO_ARRAY=$(to_list "${PROBLEM_NLO_ARRAY[@]}")
PROBLEM_DIM_ARRAY=$(to_list "${PROBLEM_DIM_ARRAY[@]}")
SOLVER_POPSIZE_ARRAY=$(to_list "${SOLVER_POPSIZE_ARRAY[@]}")
MAX_SOLVER_FE_ARRAY=$(to_list "${MAX_SOLVER_FE_ARRAY[@]}")

TRAINING_JOB_ID=`sbatch --parsable --dependency=afterok:${COMPILE_JOB_ID} --export=MAX_TRAIN_ITERATIONS=${MAX_TRAIN_ITERATIONS},NEAT_POPSIZE_ARRAY=$NEAT_POPSIZE_ARRAY,CONTROLLER_NAME_PREFIX_ARRAY=$CONTROLLER_NAME_PREFIX_ARRAY,EXPERIMENT_FOLDER_NAME_ARRAY=$EXPERIMENT_FOLDER_NAME_ARRAY,SEED_ARRAY=$SEED_ARRAY,PROBLEM_NLO_ARRAY=$PROBLEM_NLO_ARRAY,PROBLEM_DIM_ARRAY=$PROBLEM_DIM_ARRAY,SOLVER_POPSIZE_ARRAY=$SOLVER_POPSIZE_ARRAY,MAX_SOLVER_FE_ARRAY=$MAX_SOLVER_FE_ARRAY --array=0-$i src/experiments/real/scripts/hip_train_array_random_problem.sl`

TESTING_JOB_ID=""

NEAT_POPSIZE_ARRAY=()
CONTROLLER_NAME_PREFIX_ARRAY=()
EXPERIMENT_FOLDER_NAME_ARRAY=()
SEED_ARRAY=()
PROBLEM_NLO_ARRAY=()
PROBLEM_DIM_ARRAY=()
SOLVER_POPSIZE_ARRAY=()
MAX_SOLVER_FE_ARRAY=()
i=-1
for SOLVER_POPSIZE_train in 10 40 160; do
    for SOLVER_POPSIZE_test in 10 40 160; do
        i=$((i+1))

        NEAT_POPSIZE_ARRAY+=("${standard_NEAT_POPSIZE}")
        CONTROLLER_NAME_PREFIX_ARRAY+=("POPSIZE_${SOLVER_POPSIZE_train}")
        EXPERIMENT_FOLDER_NAME_ARRAY+=("${EXPERIMENT_FOLDER_NAME}")
        SEED_ARRAY+=("${i}")
        PROBLEM_NLO_ARRAY+=("${standard_NLO}")
        PROBLEM_DIM_ARRAY+=("${standard_DIM}")
        SOLVER_POPSIZE_ARRAY+=("${SOLVER_POPSIZE_test}")
        MAX_SOLVER_FE_ARRAY+=("${standard_MAX_SOLVER_FE}")
    done
done

NEAT_POPSIZE_ARRAY=$(to_list "${NEAT_POPSIZE_ARRAY[@]}")
CONTROLLER_NAME_PREFIX_ARRAY=$(to_list "${CONTROLLER_NAME_PREFIX_ARRAY[@]}")
EXPERIMENT_FOLDER_NAME_ARRAY=$(to_list "${EXPERIMENT_FOLDER_NAME_ARRAY[@]}")
SEED_ARRAY=$(to_list "${SEED_ARRAY[@]}")
PROBLEM_NLO_ARRAY=$(to_list "${PROBLEM_NLO_ARRAY[@]}")
PROBLEM_DIM_ARRAY=$(to_list "${PROBLEM_DIM_ARRAY[@]}")
SOLVER_POPSIZE_ARRAY=$(to_list "${SOLVER_POPSIZE_ARRAY[@]}")
MAX_SOLVER_FE_ARRAY=$(to_list "${MAX_SOLVER_FE_ARRAY[@]}")

TESTING_JOB_ID=`sbatch --parsable --dependency=afterok:${TRAINING_JOB_ID} --export=EXPERIMENT_FOLDER_NAME=${EXPEIMENT_FOLDER_NAME},COMPUTE_RESPONSE=${COMPUTE_RESPONSE},SCORE_PATH=${SCORE_PATH},RESPONSE_PATH=${RESPONSE_PATH},TMP_RES_PATH=${TMP_RES_PATH},N_REPS=${N_REPS},N_EVALS=${N_EVALS},EXP_NAME=${EXP_NAME},NEAT_POPSIZE_ARRAY=$NEAT_POPSIZE_ARRAY,CONTROLLER_NAME_PREFIX_ARRAY=$CONTROLLER_NAME_PREFIX_ARRAY,EXPERIMENT_FOLDER_NAME_ARRAY=$EXPERIMENT_FOLDER_NAME_ARRAY,SEED_ARRAY=$SEED_ARRAY,PROBLEM_NLO_ARRAY=$PROBLEM_NLO_ARRAY,PROBLEM_DIM_ARRAY=$PROBLEM_DIM_ARRAY,SOLVER_POPSIZE_ARRAY=$SOLVER_POPSIZE_ARRAY,MAX_SOLVER_FE_ARRAY=$MAX_SOLVER_FE_ARRAY --array=0-$i src/experiments/real/scripts/hip_test_array.sl`

sbatch --dependency=afterok:$TESTING_JOB_ID --export=SCORE_PATH=${SCORE_PATH},RESPONSE_PATH=${RESPONSE_PATH},COMPUTE_RESPONSE=${COMPUTE_RESPONSE},TMP_RES_PATH=${TMP_RES_PATH} scripts/cat_result_files_to_exp_folder.sh

###########################################################################################################################

EXP_NAME="MAX_SOLVER_FE"
NEAT_POPSIZE_ARRAY=()
CONTROLLER_NAME_PREFIX_ARRAY=()
EXPERIMENT_FOLDER_NAME_ARRAY=()
SEED_ARRAY=()
PROBLEM_NLO_ARRAY=()
PROBLEM_DIM_ARRAY=()
SOLVER_POPSIZE_ARRAY=()
MAX_SOLVER_FE_ARRAY=()

i=-1
for MAX_SOLVER_FE_train in 1000 5000 25000 125000; do
    i=$((i+1))

    NEAT_POPSIZE_ARRAY+=("${standard_NEAT_POPSIZE}")
    CONTROLLER_NAME_PREFIX_ARRAY+=("MAX_SOLVER_FE_${MAX_SOLVER_FE_train}")
    EXPERIMENT_FOLDER_NAME_ARRAY+=("${EXPERIMENT_FOLDER_NAME}")
    SEED_ARRAY+=("${i}")
    PROBLEM_NLO_ARRAY+=("${standard_NLO}")
    PROBLEM_DIM_ARRAY+=("${standard_DIM}")
    SOLVER_POPSIZE_ARRAY+=("${standard_SOLVER_POPSIZE}")
    MAX_SOLVER_FE_ARRAY+=("${MAX_SOLVER_FE_train}")
done

NEAT_POPSIZE_ARRAY=$(to_list "${NEAT_POPSIZE_ARRAY[@]}")
CONTROLLER_NAME_PREFIX_ARRAY=$(to_list "${CONTROLLER_NAME_PREFIX_ARRAY[@]}")
EXPERIMENT_FOLDER_NAME_ARRAY=$(to_list "${EXPERIMENT_FOLDER_NAME_ARRAY[@]}")
SEED_ARRAY=$(to_list "${SEED_ARRAY[@]}")
PROBLEM_NLO_ARRAY=$(to_list "${PROBLEM_NLO_ARRAY[@]}")
PROBLEM_DIM_ARRAY=$(to_list "${PROBLEM_DIM_ARRAY[@]}")
SOLVER_POPSIZE_ARRAY=$(to_list "${SOLVER_POPSIZE_ARRAY[@]}")
MAX_SOLVER_FE_ARRAY=$(to_list "${MAX_SOLVER_FE_ARRAY[@]}")

TRAINING_JOB_ID=`sbatch --parsable --dependency=afterok:${COMPILE_JOB_ID} --export=NEAT_POPSIZE_ARRAY=MAX_TRAIN_ITERATIONS=${MAX_TRAIN_ITERATIONS},$NEAT_POPSIZE_ARRAY,CONTROLLER_NAME_PREFIX_ARRAY=$CONTROLLER_NAME_PREFIX_ARRAY,EXPERIMENT_FOLDER_NAME_ARRAY=$EXPERIMENT_FOLDER_NAME_ARRAY,SEED_ARRAY=$SEED_ARRAY,PROBLEM_NLO_ARRAY=$PROBLEM_NLO_ARRAY,PROBLEM_DIM_ARRAY=$PROBLEM_DIM_ARRAY,SOLVER_POPSIZE_ARRAY=$SOLVER_POPSIZE_ARRAY,MAX_SOLVER_FE_ARRAY=$MAX_SOLVER_FE_ARRAY --array=0-$i src/experiments/real/scripts/hip_train_array_random_problem.sl`

TESTING_JOB_ID=""

NEAT_POPSIZE_ARRAY=()
CONTROLLER_NAME_PREFIX_ARRAY=()
EXPERIMENT_FOLDER_NAME_ARRAY=()
SEED_ARRAY=()
PROBLEM_NLO_ARRAY=()
PROBLEM_DIM_ARRAY=()
SOLVER_POPSIZE_ARRAY=()
MAX_SOLVER_FE_ARRAY=()
i=-1
for MAX_SOLVER_FE_train in 1000 5000 25000 125000; do
    for MAX_SOLVER_FE_test in 1000 5000 25000 125000; do
        i=$((i+1))

        NEAT_POPSIZE_ARRAY+=("${standard_NEAT_POPSIZE}")
        CONTROLLER_NAME_PREFIX_ARRAY+=("MAX_SOLVER_FE_${MAX_SOLVER_FE_train}")
        EXPERIMENT_FOLDER_NAME_ARRAY+=("${EXPERIMENT_FOLDER_NAME}")
        SEED_ARRAY+=("${i}")
        PROBLEM_NLO_ARRAY+=("${standard_NLO}")
        PROBLEM_DIM_ARRAY+=("${standard_DIM}")
        SOLVER_POPSIZE_ARRAY+=("${standard_SOLVER_POPSIZE}")
        MAX_SOLVER_FE_ARRAY+=("${MAX_SOLVER_FE_test}")
    done
done

NEAT_POPSIZE_ARRAY=$(to_list "${NEAT_POPSIZE_ARRAY[@]}")
CONTROLLER_NAME_PREFIX_ARRAY=$(to_list "${CONTROLLER_NAME_PREFIX_ARRAY[@]}")
EXPERIMENT_FOLDER_NAME_ARRAY=$(to_list "${EXPERIMENT_FOLDER_NAME_ARRAY[@]}")
SEED_ARRAY=$(to_list "${SEED_ARRAY[@]}")
PROBLEM_NLO_ARRAY=$(to_list "${PROBLEM_NLO_ARRAY[@]}")
PROBLEM_DIM_ARRAY=$(to_list "${PROBLEM_DIM_ARRAY[@]}")
SOLVER_POPSIZE_ARRAY=$(to_list "${SOLVER_POPSIZE_ARRAY[@]}")
MAX_SOLVER_FE_ARRAY=$(to_list "${MAX_SOLVER_FE_ARRAY[@]}")

TESTING_JOB_ID=`sbatch --parsable --dependency=afterok:${TRAINING_JOB_ID} --export=EXPERIMENT_FOLDER_NAME=${EXPEIMENT_FOLDER_NAME},COMPUTE_RESPONSE=${COMPUTE_RESPONSE},SCORE_PATH=${SCORE_PATH},RESPONSE_PATH=${RESPONSE_PATH},TMP_RES_PATH=${TMP_RES_PATH},N_REPS=${N_REPS},N_EVALS=${N_EVALS},EXP_NAME=${EXP_NAME},NEAT_POPSIZE_ARRAY=$NEAT_POPSIZE_ARRAY,CONTROLLER_NAME_PREFIX_ARRAY=$CONTROLLER_NAME_PREFIX_ARRAY,EXPERIMENT_FOLDER_NAME_ARRAY=$EXPERIMENT_FOLDER_NAME_ARRAY,SEED_ARRAY=$SEED_ARRAY,PROBLEM_NLO_ARRAY=$PROBLEM_NLO_ARRAY,PROBLEM_DIM_ARRAY=$PROBLEM_DIM_ARRAY,SOLVER_POPSIZE_ARRAY=$SOLVER_POPSIZE_ARRAY,MAX_SOLVER_FE_ARRAY=$MAX_SOLVER_FE_ARRAY --array=0-$i src/experiments/real/scripts/hip_test_array.sl`

sbatch --dependency=afterok:$TESTING_JOB_ID --export=SCORE_PATH=${SCORE_PATH},RESPONSE_PATH=${RESPONSE_PATH},COMPUTE_RESPONSE=${COMPUTE_RESPONSE},TMP_RES_PATH=${TMP_RES_PATH} scripts/cat_result_files_to_exp_folder.sh


<reponame>phage-nz/observer
#!/bin/bash
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6

cd /opt/observer

python3 manage.py runscript start_service  --script-args core >> /opt/observer/logs/core.log 2>&1 &
PIDS[0]=$!
python3 manage.py runscript start_service --script-args helper >> /opt/observer/logs/helper.log 2>&1 &
PIDS[1]=$!
python3 manage.py runscript start_service --script-args pastebin >> /opt/observer/logs/batch.log 2>&1 &
PIDS[2]=$!

trap "kill ${PIDS[*]}" SIGINT

wait


<filename>scripts/run.sh
#!/usr/bin/env bash
set -euo pipefail

# run.sh
#
# SUMMARY
#
#   A simple script that runs a make target in a container environment based
#   on the presence of the `USE_CONTAINER` environment variable.
#
#   This helps to reduce friction for first-time contributors, since running
#   basic commands through containers ensures they work. It is recommended
#   that frequent contributors setup local environments to improve the speed
#   of commands they are running frequently. This can be achieved by setting
#   USE_CONTAINER to none:
#
#       export USE_CONTAINER=none
#

cd "$(dirname "${BASH_SOURCE[0]}")/.."

# A workaround to prevent docker from creating directories at `./target` as
# root.
# Ran unconditionally for consistency between docker and bare execution.
scripts/prepare-target-dir.sh

case "$USE_CONTAINER" in
  docker | podman)
    echo "Executing within $USE_CONTAINER. To disable set USE_CONTAINER to none"
    echo ""
    echo "  make ... USE_CONTAINER=none"
    echo ""

    scripts/docker-compose-run.sh "$1"
    ;;

  *)
    echo "Executing locally. To use Docker set USE_CONTAINER to docker or podman"
    echo ""
    echo "  make ... USE_CONTAINER=docker"
    echo "  make ... USE_CONTAINER=podman"
    echo ""

    FILE=$(find ./scripts -name "${1}.*")

    if [ -z "$FILE" ]; then
      echo "Local invocation failed. Script not found!"
      echo ""
      echo "    scripts/${1}.*"
      echo ""
      echo "To run the ${1} target locally you must place a script in the"
      echo "/scripts folder that can be executed. Otherwise, you can use the"
      echo "service defined in /docker-compose.yml."
      exit 1
    fi

    ${FILE}
    ;;
esac


<reponame>platogo/block-fixup-merge-action
#!/bin/bash
set -euo pipefail

main() {
  echo "Current ref: ${GITHUB_REF_NAME}"
  BRANCH=${GITHUB_REF_NAME}
  echo "Current branch: ${BRANCH}"

  if [ "$BRANCH" == "master" ]; then
    echo "No check of master branch needed."
    exit 0
  fi

  # Using git directly because the $GITHUB_EVENT_PATH file only shows commits in
  # most recent push.
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin master --quiet
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --shallow-exclude=master origin ${BRANCH} --quiet

  # Get the list before the "|| true" to fail the script when the git cmd fails.
  FIXUP_LIST=`/usr/bin/git log --pretty=format:%s origin/master..origin/${BRANCH}`
  FIXUP_COUNT=`echo $FIXUP_LIST | grep -c '^fixup!' || true`
  echo "Fixup! commits: ${FIXUP_COUNT}"
  if [ "$FIXUP_COUNT" -gt "0" ]; then
    /usr/bin/git log --pretty=format:%s origin/master..origin/${BRANCH} | grep '^fixup!'
    echo "failing..."
    exit 1
  fi
}

main


<filename>scripts/deepSNV_automated_variants.sh
#!/bin/bash -l

#function deepSNV_automated_variants()
#{
	if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" ]; then #
		echo "usage deepSNV_automated_variants <bed_file> <tumor_bam> <normal_bam> <reference_fasta> <output_dir> [ --also-vcf <true/false>  --minBaseQ <25> --estimateDispersion --overdispersion <100> --estimateDirichlet --alternative <two.sided> ]"
		exit -1;
	fi

	bed_file=$1; shift # assuming the bed file does not have header lines and just starts with the regions directly, otherwise deepSNV throws and error
	tumor_bam=$1; shift
	normal_bam=$1; shift
    reference_fasta=$1; shift
	out_dir=$1; shift

	also_vcf=true
	minBaseQ=25 # default for deepSNV
	estimateDispersion=false
	overdispersion=100 # default for deepSNV model betabinomial
	estimateDirichlet=false
	alternative="two.sided"

	opts=""
	parameter_setting="alternative_${alternative}" # get one string that summarizes all the parameters set - and only specifically mentions them if they are non-default values, except for alternative

	while [ 0 -lt $# ]; do
		if [ $1 == "--also-vcf" ]; then
			shift;
			also_vcf=$1
		elif [ $1 == "--minBaseQ" ]; then
			shift;
			minBaseQ=$1
			if [ $minBaseQ != 25 ]; then
				parameter_setting="${parameter_setting}_minBaseQ${minBaseQ}"
				opts="$opts --minBaseQ $minBaseQ "
			fi
		elif [ $1 == "--estimateDispersion" ]; then
			estimateDispersion=true
			opts="$opts --estimateDispersion "
			parameter_setting="${parameter_setting}_estDispersionTRUE"
		elif [ $1 == "--overdispersion" ]; then
			shift;
			overdispersion=$1
			if [ $overdispersion != 100 ]; then
				parameter_setting="${parameter_setting}_overdisp${overdispersion}"
				opts="$opts --overdispersion $overdispersion "
			fi
		elif [ $1 == "--estimateDirichlet" ]; then
			estimateDirichlet=true
			opts="$opts --estimateDirichlet "
			parameter_setting="${parameter_setting}_estDirichletTRUE"
		elif [ $1 == "--alternative" ]; then
			shift;
			alternative=$1;
			opts="$opts --alternative $alternative "
		fi;
		shift;
	done

	echo "run deepSNV..."
	echo "opts = $opts "

        # check whether the bed file has overlapping regions -  it should not have, because otherwise deepSNV calls variants in these regions several times
        NumOverlaps=`awk 'BEGIN{chr="";end=0}{if(chr==$1 && $2<end){print};chr=$1;end=$3}' ${bed_file} | wc -l `
        if [ $NumOverlaps -gt 0 ]; then
		>&2 echo "ERROR: The bed file $bed_file contains overlapping regions."
		exit -1
        fi

	mkdir -p $out_dir

	deepSNV_script="$(dirname ${BASH_SOURCE[0]})/deepSNV_automated.R"

	command="$deepSNV_script $bed_file $tumor_bam $normal_bam $out_dir $opts"
	echo $command
	eval $command

	if $also_vcf; then
		output=$out_dir/`basename ${tumor_bam%.bam}`_vs_`basename ${normal_bam%.bam}`.txt
		fn_vcf=${output%.txt}.vcf
		if [ ! -f $fn_vcf ] ; then
			command2VCF="/cluster/work/bewi/modules/python/2.7/bin/python $(dirname ${BASH_SOURCE[0]})/deepSNV2VCF.py $output $reference_fasta $fn_vcf --no-LOH --no-indels "
            echo "$command2VCF"
            eval "$command2VCF"
		else
			echo deepSNV vcf file exists: $fn_vcf
		fi
	fi
#}


<filename>CodeFormatter.sh<gh_stars>0
#!/bin/bash

mono ./CodeFormatter/CodeFormatter.exe ./DataServicePrototype.sln


source ~/.functions_colors_shell.zsh

# functions and load-onces stuff for the environment
echo "function config"
source ~/.functions_shell.sh
source ~/.functions_colors.sh
source ~/.functions_dev.sh
source ~/.functions_osx.sh
source ~/.functions_graphics.sh

# Vim IDE settings
source ~/.bash_vim_append

test -e "${HOME}/.dotfiles/mac/iterm2_shell_integration.sh" && source "${HOME}/.dotfiles/mac/iterm2_shell_integration.sh"

alias mkdir=/bin/mkdir
alias ll='ls -alGh'

export PATH="$HOME/.dotfiles/bin:$PATH"


<gh_stars>0
#!/bin/bash
#
# sa-learn and sa report script by <NAME> https://notes.sagredo.eu
# more info here
# https://notes.sagredo.eu/en/qmail-notes-185/setting-up-a-spamassassin-cronjob-script-for-the-learning-and-reporting-systems-249.html
#
# If you want to test for a single admin user you can run in the following way:
#
# sa_cron.sh <EMAIL>
#
# otherwise, if you run it without passing any user, the job will be done for all users
# having .Spam.TeachSpam and .Spam.TeachNotSpam dirs in their Maildirs.
#
# The script is intended to be run in a cronjob.
#

DOMAINS_DIR=/var/vpopmail/domains
JUNK_DIR=.Spam.TeachSpam
HAM_DIR=.Spam.TeachNotSpam

# Set this to 1 if you want to log debug msg
DEBUG=1

# Set this to 1 if you want the spam be removed after the run
DELETE_TEACH_DATA=1

# spamassassin settings
SA_LEARN_CMD=/usr/local/bin/sa-learn
SA_CMD=/usr/local/bin/spamassassin

################### you should not modify anything below this line

# sed path
SED=""
for f in /usr/bin/sed /usr/sbin/sed /usr/local/bin/sed /usr/local/sbin/sed
do
    if test -x $f
    then
        SED=$f
        break
    fi
done
if [[ $SED == "" ]]; then
        echo "sed binary not found."
        exit 1;
fi

# Check if the program has to be run just for an admin account
if [ "$1" = "" ]; then
# if not it will run for all users
	PROCESS_ALL_USERS=1
else
	PROCESS_ALL_USERS=0
        USER=$(echo $1 | $SED -e "s/^\(.*\)@.*/\1/")
        DOMAIN=$(echo $1 | $SED -e "s/^.*@\(.*\)/\1/")
fi

run()
{
	SPAMPATH=${1}/${JUNK_DIR}
	HAMPATH=${1}/${HAM_DIR}

	if [ $DEBUG -eq 1 ]; then
		D="-D"
	else
		D=""
	fi

	if [ -e ${SPAMPATH}/new ] || [ -e ${SPAMPATH}/cur ]; then
		echo "processing spam via ${SPAMPATH}...";
		$SA_LEARN_CMD $D --no-sync --spam --username=${USER}@${DOMAIN} ${SPAMPATH}/{cur,new} 2>&1
	        for mail in ${SPAMPATH}/{cur,new}/*; do
		{
			if [ -e $mail ]; then
				#echo processing: $mail
				$SA_CMD $D --nocreate-prefs --report < $mail 2>&1
			fi
		};
		done;
	fi

	if [ -e ${HAMPATH}/new ] || [ -e ${HAMPATH}/cur ]; then
		echo
		echo "processing ham via ${HAMPATH}...";
                $SA_LEARN_CMD $D --no-sync --ham --username=${USER}@${DOMAIN} ${HAMPATH}/{cur,new} 2>&1
                for mail in ${HAMPATH}/{cur,new}/*; do
                {
			if [ -e $mail ]; then
				$SA_CMD $D --nocreate-prefs --revoke < $mail 2>&1
			fi
		};
                done;
	fi

	if [ "$DELETE_TEACH_DATA" -eq 1 ]; then
		rm -f ${SPAMPATH}/new/* ${SPAMPATH}/cur/*
		# Is it good to delete the ham as well? Not sure here...
#		rm -f ${HAMPATH}/new/* ${HAMPATH}/cur/*
	fi
}

if [ "$PROCESS_ALL_USERS" -eq 1 ]; then
	for maildir in `ls -d ${DOMAINS_DIR}/*/*/Maildir 2>/dev/null`; do
	{
		DOMAIN=$(echo $maildir | $SED -e "s|^${DOMAINS_DIR}/\(.*\)/.*/Maildir|\1|")
		  USER=$(echo $maildir | $SED -e "s|^${DOMAINS_DIR}/.*/\(.*\)/Maildir|\1|")
		run $maildir
	};
	done;
elif [ -e ${DOMAINS_DIR}/${DOMAIN}/${USER}/Maildir ]; then
	run ${DOMAINS_DIR}/${DOMAIN}/${USER}/Maildir
fi

echo
echo "syncing...";
$SA_LEARN_CMD --sync

echo
echo "current status:"
$SA_LEARN_CMD --dump magic

exit 0;


<filename>push_subtrees.sh<gh_stars>1-10
#!/bin/bash
git subtree push --prefix classes/db_stuff ~/git/php/db_stuff.git master


<reponame>sidhshar/istio
#!/usr/bin/env bash

export K8S_VER=${K8S_VER:-v1.9.2}

if [ ! -f /usr/local/bin/minikube ]; then
   curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.22.3/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
fi
if [ ! -f /usr/local/bin/kubectl ]; then
   curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.7.4/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
fi

export KUBECONFIG=${KUBECONFIG:-$GOPATH/minikube.conf}

function waitMinikube() {
    set +e
    kubectl cluster-info
    # this for loop waits until kubectl can access the api server that Minikube has created
    for i in {1..150}; do # timeout for 5 minutes
       kubectl get po &> /dev/null
       if [ $? -ne 1 ]; then
          break
      fi
      sleep 2
    done
    kubectl get svc --all-namespaces
    echo "Minikube is running"
}

# Requires sudo ! Start real kubernetes minikube with none driver
function startMinikubeNone() {
    export MINIKUBE_WANTUPDATENOTIFICATION=false
    export MINIKUBE_WANTREPORTERRORPROMPT=false
    export MINIKUBE_HOME=$HOME
    export CHANGE_MINIKUBE_NONE_USER=true
    sudo -E minikube start \
            --extra-config=apiserver.Admission.PluginNames="Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,GenericAdmissionWebhook,ResourceQuota" \
            --kubernetes-version=v1.7.5 --vm-driver=none
    sudo -E minikube update-context
    sudo chown -R $(id -u) $KUBECONFIG $HOME/.minikube
}

function stopMinikube() {
    sudo minikube stop
}

case "$1" in
    start) startMinikubeNone ;;
    stop) stopMinikube ;;
    wait) waitMinikube ;;
esac


#!/usr/bin/env bash

CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/helpers.sh"

SESSIONS_DIR="$(sessions_dir)"
TIMEOUT="$(tmux_option "@browser_wait_timeout" "5.0")"

current_session=$(tmux display-message -p '#S')
# Using localhost to don't query any web browser
tab_id_name=localhost:1212/dont_close-tmux-browser_$current_session

focus_tabid_window()
{
	if ! command -v wmctrl &> /dev/null
	then
		return
	fi

	window_id=$1
	active_window_title=$(bt query +active -windowId $window_id | cut -f2)
	echo $TIMEOUT
	wmctlr_window_id=$(timeout $TIMEOUT "$CURRENT_DIR/wait_for_active_window.sh" $active_window_title)
	if [ -z "$wmctlr_window_id" ]; then
		tmux display "[ERROR] Active window not found, not jumping."
		exit 0
	fi
	wmctrl -i -R $wmctlr_window_id
}

tmux display "[INFO] tmux-browser: Opening Browser!"
bt_list=$(bt list)
if echo "$bt_list" | grep -q "$tab_id_name$"; then
	tmux display "[INFO] Session is already running!"
	window_id=$(echo "$bt_list" | cut -f1,3 | grep "$tab_id_name$" | cut -f2 -d ".")
	focus_tabid_window $window_id
	exit 0
fi

# TODO: pin the tab
eval "$(tmux_option "@new_browser_window" "screen -dm -- firefox --new-window")" "http://$tab_id_name"
window_id=$(timeout $TIMEOUT "$CURRENT_DIR/wait_for_new_window.sh" $tab_id_name)

if [ -z "$window_id" ]; then
	tmux display "[ERROR] Web browser window didnt found"
	exit 0
fi

if [[ $(echo $window_id | tr -cd ' \t' | wc -c) != '0' ]]; then
	tmux display "[ERROR] Multiple windows with the same tab id name: $tab_id_name"
	exit 0
fi

if [ -f "$SESSIONS_DIR/$current_session" ]; then
	tmux display "Restoring from $SESSIONS_DIR/$current_session"
	bt open $window_id < "$SESSIONS_DIR/$current_session"
else
	tmux display "New Browser Opened"
fi

window_id=$(echo $window_id | cut -f2 -d ".")
focus_tabid_window $window_id
exit 0


#!/bin/bash

# shellcheck disable=SC1091

set -o errexit
set -o nounset
set -o pipefail
# set -o xtrace # Uncomment this line for debugging purpose

# Load Grafana environment
. /opt/bitnami/scripts/grafana-env.sh

# Load libraries
. /opt/bitnami/scripts/libos.sh
. /opt/bitnami/scripts/liblog.sh

declare cmd="grafana-server"
declare -a args=(
    # Based on https://github.com/grafana/grafana/blob/v8.2.5/packaging/docker/run.sh
    "--homepath=${GF_PATHS_HOME}"
    "--config=${GF_PATHS_CONFIG}"
    "--packaging=docker"
    "$@"
    "cfg:default.log.mode=console"
    "cfg:default.paths.data=${GF_PATHS_DATA}"
    "cfg:default.paths.logs=${GF_PATHS_LOGS}"
    "cfg:default.paths.plugins=${GF_PATHS_PLUGINS}"
    "cfg:default.paths.provisioning=${GF_PATHS_PROVISIONING}"
)

cd "$GRAFANA_BASE_DIR"

info "** Starting Grafana **"
if am_i_root; then
    exec gosu "$GRAFANA_DAEMON_USER" "$cmd" "${args[@]}"
else
    exec "$cmd" "${args[@]}"
fi


<reponame>BernLeWal/raskeytar_webapp<filename>run-python.sh
#!/bin/bash
docker rm raskeytarapp1 >/dev/null
docker run -t -d -p 8080:8080 --name raskeytarapp1 raskeytarapp-python
echo Container named raskeytarapp1 started
echo .
echo Open http://127.0.0.1:8080/ in your browser.
echo .
echo Run "docker stop raskeytarapp1" to shutdown container.


#!/usr/bin/env bash
# Runs instrumentation tests on firebase. Must be run locally, not on travis.
#
# Usage:
# ./scripts/run_instrumentation_test.sh

./gradlew :instrumentation:assembleDebug :instrumentation:assembleDebugAndroidTest --parallel

apk_dir=instrumentation/build/outputs/apk
gcloud firebase test android run \
  --type instrumentation \
  --app $apk_dir/instrumentation-debug.apk \
  --test $apk_dir/instrumentation-debug-androidTest.apk \
  --device model=Nexus6P,version=26,locale=en,orientation=portrait \
  --device model=Nexus6P,version=25,locale=en,orientation=portrait \
  --device model=Nexus6P,version=23,locale=en,orientation=portrait \
  --device model=Nexus6,version=22,locale=en,orientation=portrait \
  --device model=Nexus5,version=19,locale=en,orientation=portrait \
  --project android-glide \
  --no-auto-google-login


<filename>clean_and_build.sh
#!/bin/sh
rm -r ./build
sh ./build.sh


<gh_stars>0
#!/bin/bash

function read_current_cpu_temperature() {
    #echo `sensors | grep temp1 | sed 1d | awk '{print $2}' | cut -c 2-3`
    echo `sensors | grep Tdie | awk '{print $2}' | cut -c 2-3`
}

function read_current_liquid_temperature() {
    var=$(colctl -s | grep liquid | cut -d' ' -f2)
    echo ${var%.*}
}

function get_best_fan_speed() {
    current_cpu_temp=$(read_current_cpu_temperature)
    current_liqiod_temp=$(read_current_liquid_temperature)

    if (( ${current_cpu_temp} >= 75 )); then
	fan_speed=100
    elif (( ${current_cpu_temp} >= 70 )); then
	fan_speed=100
    elif (( ${current_cpu_temp} >= 65 )); then
	fan_speed=100
    elif (( ${current_cpu_temp} >= 60 )); then
	fan_speed=100
    elif (( (${current_cpu_temp} >= 55) || (${current_liquid_temp} >= 40))); then
	fan_speed=100
    elif (( (${current_cpu_temp} >= 55) || (${current_liquid_temp} >= 38))); then
	fan_speed=75
    elif (( ${current_cpu_temp} >= 50 )); then
	fan_speed=50
    elif (( (${current_cpu_temp} >= 30) || (${current_liquid_temp} >= 35))); then
	fan_speed=50
    else
	fan_speed=25
    fi

    echo $fan_speed
}

function get_best_pump_speed() {
    current_cpu_temp=$(read_current_cpu_temperature)
    current_liquid_temp=$(read_current_liquid_temperature)

    if (( ${current_cpu_temp} >= 75 )); then
	pump_speed=100
    elif (( ${current_cpu_temp} >= 70 )); then
	pump_speed=100
    elif (( ${current_cpu_temp} >= 60 )); then
	pump_speed=100
    elif (( ${current_cpu_temp} >= 40 )); then
	pump_speed=75
    elif (( (${current_cpu_temp} >= 35) || (${current_liquid_temp} >= 35))); then
	pump_speed=75
    else
	pump_speed=75
    fi

    echo $pump_speed
}

function set_fan_and_pump_speed() {
    echo "Setting fan speed to $1 and pump speed to $2"
    colctl -fs $1 -ps $2
    echo
}

die() {
    echo "$@" 1>&2
    exit 1
}

STEP_DELAY_SECONDS=2

function fan_control {
    FAN_STATUS="on"
    while [ true ];
    do
	current_cpu_temp=$(read_current_cpu_temperature)
	current_liquid_temp=$(read_current_liquid_temperature)

	echo "Current CPU temperature $current_cpu_temp"
	echo "Current liquid temperature $current_liquid_temp"

	best_fan_speed=$(get_best_fan_speed)
	best_pump_speed=$(get_best_pump_speed)

	set_fan_and_pump_speed $best_fan_speed $best_pump_speed

	sleep $STEP_DELAY_SECONDS
    done
}

fan_control


#!/bin/bash
echo "" > results/efficiency.txt
for i in `seq $1`; do
	#Generates a random stimulus order
	RSFgen \
	-nt 300 \
	-num_stimts 3 \
	-nreps 1 20 \
	-nreps 2 20 \
	-nreps 3 20 \
	-seed $i \
	-prefix times/stim_${i}_
	#Converts the RSFgen output to times
	make_stim_times.py \
	-files times/stim_${i}_*.1D \
	-prefix stimt_${i} \
	-nt 300 \
	-tr 1 \
	-nruns 1
	#Evaluates the design using 3dDeconvolve (redirecting the output to a file)
	3dDeconvolve -nodata 300 1 -polort 1 \
	-num_stimts 3 \
	-stim_times 1 times/stimt_${i}.01.1D 'GAM' -stim_label 1 'A' \
	-stim_times 2 times/stimt_${i}.02.1D 'GAM' -stim_label 2 'B' \
	-stim_times 3 times/stimt_${i}.03.1D 'GAM' -stim_label 3 'C' \
	-gltsym "SYM: A -B" -gltsym "SYM: A -C" \
	> times/RSFgen_output_${i}.txt
	#-xjpeg times/design_${i}.png \

	#Runs the provided efficiency_parser.py script on the 3dDeconvolve output file.
		#This script will parse the 3dDeconvolve ouptut and print out the average efficiency of any
		#contrasts you have specified.
	efficiency=`scripts/efficiency_parser.py times/RSFgen_output_${i}.txt`
	#Prints out two columns for each design, the first containing the efficiency and the second containing the seed
		#Hint: Use `` to store the output efficiency_parser.py in a variable
		#You can print the required values with something like echo "$efficiency $i"
	echo "$efficiency $i" >> results/efficiency.txt

done


<filename>scripts/aarch64-linux-gnu-clang.sh
#!/bin/bash

clang --target=aarch64-linux-gnu "$@"


#!/bin/bash

set -e

echo OPTIMISTIC_ABOUT_FILE_LOCKING = 1 >> ${SPLUNK_HOME_TCP}/etc/splunk-launch.conf
echo OPTIMISTIC_ABOUT_FILE_LOCKING = 1 >> ${SPLUNK_HOME_SSL}/etc/splunk-launch.conf

SPLUNK_HOME=$SPLUNK_HOME_TCP sudo -HEu ${SPLUNK_USER} ${SPLUNK_HOME_TCP}/bin/splunk start --accept-license
SPLUNK_HOME=$SPLUNK_HOME_SSL sudo -HEu ${SPLUNK_USER} ${SPLUNK_HOME_SSL}/bin/splunk start --accept-license

# Trap exit signal and shutdown gracefully
trap "sudo -HEu ${SPLUNK_USER} ${SPLUNK_HOME_TCP}/bin/splunk stop; sudo -HEu ${SPLUNK_USER} ${SPLUNK_HOME_SSL}/bin/splunk stop" SIGINT SIGTERM EXIT

sudo -HEu ${SPLUNK_USER} tail -n 0 -f ${SPLUNK_HOME_TCP}/var/log/splunk/splunkd_stderr.log &
wait


#PBS -A PAA0028
#PBS -l walltime=01:00:00
#PBS -l nodes=1:ppn=40 -q debug
#PBS -N si_job_name
#PBS -e job.err
#PBS -o job.out
#PBS -S /bin/bash

echo "The current hostname is $HOSTNAME"

echo "The current working directory is $(pwd)"
echo "Switching to the working directory $PBS_O_WORKDIR"
cd $PBS_O_WORKDIR

echo "switching compiler chain"
echo "module load intel/19.0.5"
module load intel/19.0.5
echo "module load intelmpi/2019.3"
module load intelmpi/2019.3

echo "VASP_STD_BIN=$VASP_STD_BIN"
mpiexec $VASP_STD_BIN


<reponame>MikalDev/babylon-sprite
cd ./src
zip -r ../dist/BabylonModel$1.c3addon *
cd ..


#!/bin/bash
set -e
for FILE in $(ls test/*.js); do
  echo -n "${FILE: 0: ${#FILE}-3}.."
  ./rusttojs ${FILE: 0: ${#FILE}-3}.rs|diff - ${FILE}
  echo "OK"
done


<reponame>HFauto/CNStream
#!/bin/bash
CURRENT_DIR=$(cd $(dirname ${BASH_SOURCE[0]});pwd)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/neuware/lib64/

src_dir="$CURRENT_DIR/../../data"
models_dir="$CURRENT_DIR/../../data/models"
dst_dir="$CURRENT_DIR/src/webui/static"
pushd $dst_dir
  if [ ! -d $dst_dir/data ]; then
    echo "generate source data"
    mkdir data
    cp $src_dir/videos/cars.mp4 data/
    cp $src_dir/videos/1080P.h264 data/
  else
    if [ ! -f $dst_dir/data/cars.mp4 ]; then
      echo "copy cars.mp4"
      cp $src_dir/videos/cars.mp4 data/
    fi
    if [ ! -f $dst_dir/data/1080P.h264 ]; then
      echo "copy 1080P.h264"
      cp $src_dir/videos/1080P.h264 data/
    fi
  fi

  pushd $models_dir
    resnet50_model_name="resnet50_b16c16_bgra_mlu270.cambricon"
    resnet50_label_name="synset_words.txt"
    if [ ! -f $resnet50_model_name ]; then
      echo "download renset50"
      wget -O $resnet50_model_name http://video.cambricon.com/models/MLU270/Classification/resnet50/resnet50_offline_v1.3.0.cambricon
    fi
    if [ ! -f $resnet50_label_name ]; then
      echo "download renset50 label"
      wget -O $resnet50_label_name http://video.cambricon.com/models/MLU270/Classification/resnet50/synset_words.txt
    fi
    ssd_model_name="resnet34_ssd_b16c16_mlu270.cambricon"
    ssd_label_name="label_voc.txt"
    if [ ! -f $ssd_model_name ]; then
      echo "download ssd"
      wget -O $ssd_model_name http://video.cambricon.com/models/MLU270/Primary_Detector/ssd/resnet34_ssd.cambricon
    fi
    if [ ! -f $ssd_label_name ]; then
      echo "download ssd label"
      wget -O $ssd_label_name http://video.cambricon.com/models/MLU270/Primary_Detector/ssd/label_voc.txt
    fi
    yolov3_model_name="yolov3_b4c4_argb_mlu270.cambricon"
    yolov3_label_name="label_map_coco.txt"
    if [ ! -f $yolov3_model_name ]; then
      echo "download yolov3"
      wget -O $yolov3_model_name http://video.cambricon.com/models/MLU270/yolov3/yolov3_4c4b_argb_270_v1.5.0.cambricon
    fi
    if [ ! -f $yolov3_label_name ]; then
      echo "download yolov3 label"
      wget -O $yolov3_label_name http://video.cambricon.com/models/MLU270/yolov3/label_map_coco.txt
    fi
    feature_extract_model_name="feature_extract_for_tracker_b4c4_argb_mlu270.cambricon"
    if [ ! -f $feature_extract_model_name ]; then
      echo "download feature extract model"
      wget -O $feature_extract_model_name http://video.cambricon.com/models/MLU270/feature_extract/feature_extract_4c4b_argb_270_v1.5.0.cambricon
    fi
  popd

  pushd $dst_dir
    if [ -d "models" ]; then
      rm -rf "models"
    fi
    ln -s $src_dir"/models" .
  popd
popd

start_webserver() {
pushd src
 gunicorn -c ../webserver_config.py wsgi:app
popd
}

start_webserver


<filename>code/player.sh
#!/bin/bash

# LIBRARIES (SORTA)
. code/manager.sh

for f in $PiRadio_DIR/music/"$PiRadio_name"/*
do
	clear
	PiRadio_file=$(basename "$f")
	export PiRadio_file
	freqUsed
	echo
	$PiRadio_DIR/fm_transmitter-master/fm_transmitter -f $PiRadio_freq -r "$f"		# STARTS A NEW SCREEN AND THEN STARTS RADIO IN $freq WITH $f SONG
done
unset PiRadio_file
exit


if [[ -f /usr/local/bin/dayone2 ]] ; then
  alias dayo="/usr/local/bin/dayone2"
  alias dayone="/usr/local/bin/dayone2"
fi


<gh_stars>0
#!/bin/sh

# 卸载老版本

yum remove -y kube-proxy

yum remove -y kubelet

yum remove -y kube-scheduler

yum remove -y kube-controller-manager

yum remove -y kube-apiserver

yum remove -y flanneld

yum remove -y etcd

yum remove -y docker


<reponame>Sephta/stal-vpet-rpg
cd ./client;
npm run start;


<filename>run_gles_trace.sh
#!/bin/sh
set -e
set -x

if [ $# = 0 ]; then
  echo "[usage] run_gles_trace.sh /path/to/gles_app"
  exit 1
fi

# ------------------------------------------------------------------
# If application doesn't link "libEGL.so" (probably application use dlopen("libEGL.so"))
# fake "libEGL.so" and "libGLESv2.so" (symbolic linked to libGLEStrace.so)
# must be placed on the first place of LD_LIBRARY_PATH.
#
#    $ ./run_gles_trace.sh /path/to/gles_app
# ------------------------------------------------------------------

export GLES_TRACE_DIR=`dirname $(realpath $0)`

ln -f -s ${GLES_TRACE_DIR}/libGLEStrace.so ${GLES_TRACE_DIR}/libEGL.so
ln -f -s ${GLES_TRACE_DIR}/libGLEStrace.so ${GLES_TRACE_DIR}/libEGL.so.1
ln -f -s ${GLES_TRACE_DIR}/libGLEStrace.so ${GLES_TRACE_DIR}/libEGL.so.1.0.0
ln -f -s ${GLES_TRACE_DIR}/libGLEStrace.so ${GLES_TRACE_DIR}/libGLESv2.so
ln -f -s ${GLES_TRACE_DIR}/libGLEStrace.so ${GLES_TRACE_DIR}/libGLESv2.so.2
ln -f -s ${GLES_TRACE_DIR}/libGLEStrace.so ${GLES_TRACE_DIR}/libGLESv2.so.2.0.0

export LD_LIBRARY_PATH=${GLES_TRACE_DIR}/:$LD_LIBRARY_PATH

if [ -e /usr/lib/aarch64-linux-gnu/libEGL.so ]; then
  export GLES_TRACE_REAL_LIBEGL=/usr/lib/aarch64-linux-gnu/libEGL.so
  export GLES_TRACE_REAL_LIBGLES=/usr/lib/aarch64-linux-gnu/libGLESv2.so
elif [ -e /usr/lib/aarch64-linux-gnu/libEGL.so ]; then
  export GLES_TRACE_REAL_LIBEGL=/usr/lib/x86_64-linux-gnu/libEGL.so
  export GLES_TRACE_REAL_LIBGLES=/usr/lib/x86_64-linux-gnu/libGLESv2.so
else
  export GLES_TRACE_REAL_LIBEGL=/usr/lib/libEGL.so
  export GLES_TRACE_REAL_LIBGLES=/usr/lib/libGLESv2.so
fi

#-------------------
# Customize options
#-------------------
export GLES_TRACE_LOG_FILE="trace_log.txt"

export GLES_TRACE_CAPTURE_ON_DRAW=1
export GLES_TRACE_CAPTURE_ON_SWAP=1
export GLES_TRACE_DUMP_TEXTURE=1
export GLES_TRACE_GETERROR_ON_DRAW=1
export GLES_TRACE_GETERROR_ON_SWAP=1
export GLES_TRACE_FORCE_LINE_RENDER=0

#export GLES_TRACE_FORCE_GL_VERSION="OpenGL ES 2.0"
#export GLES_TRACE_FORCE_GL_VENDOR="Dummy vendor"
#export GLES_TRACE_FORCE_GL_RENDERER="Dummy renderer"
#export GLES_TRACE_FORCE_GL_EXTENSIONS="Dummy_extension"

# -------------
# launch app
# -------------
$@