<gh_stars>10-100
export ALGOD_ENDPOINT="https://testnet-algorand.api.purestake.io/ps2"
export ALGOD_TOKEN="<KEY>"
export INDEXER_ENDPOINT="https://testnet-algorand.api.purestake.io/idx2"
export INDEXER_TOKEN="$<PASSWORD>OD_<PASSWORD>"

export DEVELOPER_ACCOUNT_PRIVATE_KEY="plastic knee brush fall estate object blast harbor ethics acoustic wheat road parade allow tumble rally spell goddess someone coil disorder trumpet peanut above awkward"
export TEST_ACCOUNT_PRIVATE_KEY="ladder main horn village pave disease effort surround stool purpose clown cereal sick stamp estate hotel foot argue blood mobile pattern maximum human able grunt"

export ESCROW_ADDRESS="R3CB4EH5HBPWU5DT7QUFSXFNP44QFAUZYCVKCQIPIPTGPTCMHQC2JIOAVA"
export ESCROW_LOGICSIG="<KEY>

export MANAGER_INDEX="14973861"
export VALIDATOR_INDEX="14973862"
export TOKEN1_INDEX="1<PASSWORD>"
export TOKEN2_INDEX="<PASSWORD>"
export LIQUIDITY_TOKEN_INDEX="14973866"


#!/bin/sh

# CONTROL register
#
# D1-D0
#  stand by : 0
#  forward  : 1
#  revarsal : 2
#  brake    : 3
#
# D7-D2
#  0x06 0.48V
#  0x07 0.56V
#  0x08 0.64V
#  ...
#  0x3f 5.06V

# stand by, 5.06V
#   0 + (0x3f << 2) = 252
sudo echo "set_motor 100 252" >> /dev/rfcomm0
cat /dev/rfcomm0
# sleep 1

# forward, 5.06V
#   1 + (0x3f << 2) = 253
# echo "set_motor 100 253" >> /dev/rfcomm0
# sleep 1

# stand by, 5.06V
#   0 + (0x3f << 2) = 252
# sudo echo "set_motor 100 252" >> /dev/rfcomm0
# sleep 1

# revarsal, 5.06V
#   2 + (0x3f << 2) = 254
# sudo echo "set_motor 100 254" >> /dev/rfcomm0
# sleep 1

# brake, 5.06V
#   3 + (0x3f << 2) = 255
# sudo echo "set_motor 100 255" >> /dev/rfcomm0
# sleep 1


#!/usr/bin/env bash

# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2021 Micron Technology, Inc. All rights reserved.

#doc: quick longtest focused on cn cursors

. common.subr

trap kvdb_drop EXIT
kvdb_create

kvs=$(kvs_create smoke-0) || exit $?

threads=4
keys=100000
iter=3
#absolute key min is 6, per longtest command parser
kmin=6
#absolute key max is 8, because rsgen_decode() cannot handle more
kmax=8

cmd longtest "$home" "$kvs" -t "$threads" -i "$iter" -c "$keys" "--kmin=$kmin" "--kmax=$kmax" --cursor
cmd cndb_log -c "$home"
cmd cn_metrics "$home" "$kvs"


<filename>src/libs/path.sh
#!/usr/bin/env bash
# Copyright (c) 2021 maminjie <<EMAIL>>
# SPDX-License-Identifier: MulanPSL-2.0

# path_expand path
#   Expand path (~)
path_expand() {
    eval echo "$1"
}

# path_absolute path
path_absolute() {
    readlink -f "$1"
}


cd src
python main.py single_pose --exp_id coac_movenet --dataset active_coco --dataset active_coco --arch movenet --batch_size 24 --master_batch 4 --lr 2.5e-4 --gpus 0,1,2,3 --num_epochs 250 --lr_step 120,150,180,200,230 --num_workers 16 --resume #--load_model ../models/ctdet_movenet.pth
# test
python test.py single_pose --exp_id coac_movenet --dataset active_coco --arch movenet --keep_res --resume
# flip test
python test.py single_pose --exp_id coac_movenet --dataset active_coco --arch movenet --keep_res --resume --flip_test
cd ..


<filename>deploy.sh
#!/bin/bash
# Script for deploying a jekyll build to AWS and purging Cloudflare cache

# Push the build using the s3_website.yml settings
bundle exec s3_website push

# Clear the Cloudflare cache
curl https://www.cloudflare.com/api_json.html \
    -d 'a=fpurge_ts' \
    -d "tkn=$cloudflare_token" \
    -d "email=$cloudflare_email" \
    -d "z=$cloudflare_zone" \
    -d 'v=1'


rm default.metallib travel
xcrun clang++ -std=c++20 travel.mm -framework MetalKit -framework Metal -framework Foundation -O2 -o travel
xcrun metal -O2 travel.metal
#AGC_ENABLE_STATUS_FILE=1 FS_CACHE_SIZE=0 USE_MONOLITHIC_COMPILER=1


#!/usr/bin/env bash

set -e
set -x

CURRENT_BRANCH="6.x"

function split()
{
    SHA1=`splitsh-lite --prefix=$1`
    git push $2 "$SHA1:refs/heads/$CURRENT_BRANCH" -f
}

function add_remote()
{
    git remote add $1 $2 || true
}

function remove_remote()
{
    git remote remove $1 || true
}

git pull origin $CURRENT_BRANCH

add_remote core <EMAIL>:orchestral/support-core.git
add_remote facades <EMAIL>:orchestral/support-facades.git
add_remote providers <EMAIL>:orchestral/support-providers.git

split 'src/Support' core
split 'src/Facades' facades
split 'src/Providers' providers

remove_remote core
remove_remote facades
remove_remote providers


<filename>stop-service.sh
#!/bin/bash -xe

source /home/ec2-user/.bash_profile
[ -d "/home/ec2-user/app/release" ] && \ cd /home/ec2-user/app/release && \

sudo docker-compose down

sudo docker system prune --all --force --volumes


<filename>test/schema/install_faker.sh
#!/bin/bash
mkdir -p test/schema/faker
curl https://raw.githubusercontent.com/jbranchaud/pg_faker/master/sql/first_names.sql -o test/schema/faker/first_names.sql
curl https://raw.githubusercontent.com/jbranchaud/pg_faker/master/sql/last_names.sql -o test/schema/faker/last_names.sql
curl https://raw.githubusercontent.com/jbranchaud/pg_faker/master/sql/functions.sql -o test/schema/faker/functions.sql


<reponame>sshniro/docker_setup
#!/usr/bin/env bash

# create local docker image
docker build -t nimbleplatform/marmotta-backend --build-arg DB_HOST=marmotta-db --build-arg DB_PORT=5432 --build-arg DB_USER=root --build-arg DB_PASS=<PASSWORD> .

# push to docker hub
docker push nimbleplatform/marmotta-backend

# add to Bluemix container registry
bx ic cpi nimbleplatform/marmotta-backend registry.eu-gb.bluemix.net/semantic_mediator_container/marmotta-backend

# create volume for settings (optional)
# bx ic volume-create marmotta-settings

# run postgres container
bx ic run --name marmotta-db \
	-e "POSTGRES_PASSWORD=<PASSWORD>"\
	-e "POSTGRES_USER=root" \
	-e "POSTGRES_DB=marmotta" \
	-p 5432:5432 \
	-m 256 registry.eu-gb.bluemix.net/semantic_mediator_container/postgre

# run marmotta
bx ic run --name marmotta-backend \
	-v /var/lib/marmotta \
	--link marmotta-db:marmotta-db \
	-p 8080:8080 \
	-v marmotta-settings:/var/lib/marmotta \
	-m 2048 registry.eu-gb.bluemix.net/semantic_mediator_container/marmotta-backend


<reponame>Tricentis/qTest
str1="$( grep -w 'version:' Chart.yaml | grep -v 'version: \"*\"')"
minorVS="${str1##*.}"
echo Current version $str1
minorVS=$((minorVS+1))
str2="${str1%.*}.$minorVS"
echo Update to version $str2
sed -i "/\"/!s/version:.*/$str2/g" Chart.yaml

str3="$(grep -w 'appVersion:' Chart.yaml)"
echo Current appVersion $str3


#!/bin/bash
sudo ir-keytable -p unknown -p other -p lirc -p rc-5 -p jvc -p sony -p nec -p sanyo -p rc-6 -p sharp -p xmp 2> /dev/null
stdbuf -o L ir-keytable -t | python remote-gtts/remote2gtts.py


/bin/sh -c "
  while ! nc -z $DB_HOST $DB_PORT;
  do
    echo 'Waiting database';
    sleep 1;
  done;
  echo 'Database ready!'!;
"

npm run migrate
npm run dev


#! /bin/bash

set -e
set -u
set -o pipefail

# Run test
# Do nothing


#!/bin/bash
# Copyright (C) 2021 <NAME>.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Authors:
# <NAME> <<EMAIL>>

_scriptdir="$(dirname "${0}")"
. "${_scriptdir}/../../../script_common/common.sh" || exit 1

if [[ $(which go >/dev/null 2>&1 && echo $?) -ne 0 ]]; then
    failure "failed to find go executable in PATH"
fi

if [[ "${GOPATH}" == "" ]]; then
    GOPATH=$(go env GOPATH)
    export GOPATH
fi

make_directory "${GOPATH}/bin"
make_directory "/tmp/go/bin"
make_directory "/tmp/go/pkg"
make_directory "/tmp/go/src"

# Override the current GOPATH to protect source trees

OLD_GO_PATH="${GOPATH}"
GOPATH="/tmp/go"
export GOPATH

# all of the tools to download
GO_GET_PATHS=('github.com/klauspost/asmfmt/cmd/asmfmt'
              'honnef.co/go/tools/...'
              'github.com/timakin/bodyclose'
              'github.com/bkielbasa/cyclop/cmd/cyclop'
              'github.com/tsenart/deadcode'
              'github.com/go-delve/delve/cmd/dlv'
              'github.com/mibk/dupl'
              'github.com/kisielk/errcheck'
              'github.com/polyfloyd/go-errorlint'
              'github.com/davidrjenni/reftools/cmd/fillstruct'
              'github.com/davidrjenni/reftools/cmd/fillswitch'
              'github.com/davidrjenni/reftools/cmd/fixplurals'
              '4d63.com/gochecknoinits'
              'github.com/uudashr/gocognit/cmd/gocognit'
              'github.com/jgautheron/goconst/cmd/goconst'
              'github.com/alecthomas/gocyclo'
              'github.com/rogpeppe/godef'
              'github.com/zmb3/gogetdoc'
              'golang.org/x/tools/cmd/goimports'
              'github.com/fatih/gomodifytags'
              'golang.org/x/tools/gopls@latest'
              'golang.org/x/tools/cmd/gorename'
              'github.com/securego/gosec/cmd/gosec/...'
              'github.com/jstemmer/gotags'
              'github.com/cweill/gotests/...'
              'golang.org/x/tools/cmd/guru'
              'github.com/koron/iferr'
              'github.com/gordonklaus/ineffassign'
              'github.com/josharian/impl'
              'honnef.co/go/tools/cmd/keyify'
              'github.com/go-lintpack/lintpack/...'
              'github.com/fatih/motion'
              'github.com/alexkohler/nakedret'
              'github.com/mgechev/revive'
              'gitlab.com/opennota/check/cmd/structcheck'
              'github.com/mdempsky/unconvert'
              'mvdan.cc/unparam'
              'gitlab.com/opennota/check/cmd/varcheck'
              'github.com/go-critic/go-critic/cmd/gocritic'
              'github.com/golangci/golangci-lint/cmd/golangci-lint')

# download the tools
for getpath in "${GO_GET_PATHS[@]}"
do
    print_info "GO111MODULE=on go get ${getpath}"
    GO111MODULE=on go get "${getpath}" >/dev/null 2>&1 || failure "Failed to compile ${getpath}"
done

# reset gopath
GOPATH="${OLD_GO_PATH}"
export GOPATH

# copy the build binaries to the real GOPATH
cd_or_error "/tmp/go/bin"
for i in *
do
    install_file 0755 "${i}" "${GOPATH}/bin/${i}"
done

# cleanup, which includes fixing permissions because the source download
# sets weird permissions
cd_or_error /tmp/go
find . -type d -print0 | xargs -0 chmod 0755 || failure "Failed to fix directory permissions "
find . -type f -print0 | xargs -0 chmod 0644 || failure "Failed to fix file permissions"
cd_or_error /tmp
rm -rf go || failure "Failed to delete temporary go directory"

print_info "-"
print_info "This script can be re-run in the future to update any installed tools."
print_info "-"


<reponame>SunghoLee/incubator-tvm
#!/bin/sh

clang -I /home/eshaj/Documents/repo/klee/include/ $@


echo "should give warnings about percent data, values greater than 1 but no errors:"
python Scripts/ParseSpec.py Test/Test1
echo "========================================="
echo
echo "should give a error about no spec data:"
python Scripts/ParseSpec.py Test/Test_empty
echo "========================================="
echo
echo "should give a error about wrong column separator:"
python Scripts/ParseSpec.py Test/Test_comma
echo "========================================="
echo
echo "should give a error about incomplete dataset:"
python Scripts/ParseSpec.py Test/Test_incomplete
echo "========================================="
echo
echo "should give a error about headers in dataset:"
python Scripts/ParseSpec.py Test/Test_header
echo "========================================="
echo
echo "should give a error about non-numeric data in the first column:"
python Scripts/ParseSpec.py Test/Test_non_numeric
echo "========================================="
echo
echo "should give a error about mixed subfolders and datafiles:"
python Scripts/ParseSpec.py Test/Test_mixed


<gh_stars>0
mvn -f src/pom.xml install -P scala-2.12_spark-3.1.1 -D skipTests


#!/bin/bash -e

export AWS_ACCESS_KEY_ID="${aws_access_key}"
export AWS_SECRET_ACCESS_KEY="${aws_secret_key}"
export AWS_DEFAULT_REGION="${region}"

aws elb register-instances-with-load-balancer --load-balancer-name ${lb_name} --instances ${instance_id}


<filename>InstallVM.sh<gh_stars>1-10
# /bin/bash
# Launch a hi1.4xlarge instance

# Add public key
# Add hostname
sudo -i
cat /etc/hostname
vim /etc/hosts
127.0.0.1 euca-10-11-1-173

# Install essentials
sudo apt-get update && sudo apt-get install -y build-essential ca-certificates curl git libbz2-1.0 libc6 libffi6 libncurses5 libreadline6-dev libsqlite3-0 libsqlite3-dev libssl-dev libtinfo5 pkg-config unzip vim wget zlib1g

git clone https://github.com/heronalps/STOIC

# MySQL Server installation

sudo apt install mysql-server

# Don't install VALIDATE PASSWORD plugin
sudo mysql_secure_installation

systemctl status mysql.service

# kubbectl

curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl

chmod +x ./kubectl

sudo mv ./kubectl /usr/local/bin/kubectl

# Go
curl -LO https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz
sudo tar -C /usr/local/ -xzf go1.13.5.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

# kubectx

git clone https://github.com/ahmetb/kubectx.git ~/.kubectx
COMPDIR=$(pkg-config --variable=completionsdir bash-completion)
ln -sf ~/.kubectx/completion/kubens.bash $COMPDIR/kubens
ln -sf ~/.kubectx/completion/kubectx.bash $COMPDIR/kubectx
cat << FOE >> ~/.bashrc

#kubectx and kubens
export PATH=~/.kubectx:\$PATH
FOE
source ~/.bashrc

# Kubeless
export OS=$(uname -s| tr '[:upper:]' '[:lower:]')
export RELEASE=$(curl -s https://api.github.com/repos/kubeless/kubeless/releases/latest | grep tag_name | cut -d '"' -f 4)
curl -OL https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless_$OS-amd64.zip && \
  unzip kubeless_$OS-amd64.zip && \
  sudo mv bundles/kubeless_$OS-amd64/kubeless /usr/local/bin/

# jq
sudo apt-get install jq

# bc
sudo apt install bc

# Python

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.6
sudo ln -s /usr/bin/python3.6 /usr/bin/python

# GPU_Serverless
git clone https://github.com/heronalps/GPU_Serverless
cd GPU_Serverless
sudo apt install virtualenv
virtualenv venv --python=python3.6
source venv/bin/activate

pip install -r requirements.txt
mkdir data

scp -r ./checkpoints/ ubuntu@172.16.31.10:~/GPU_Serverless/
scp -r ./data/SantaCruzIsland_Labeled_5Class/ ubuntu@172.16.31.10:~/GPU_Serverless/data
scp -r ./data/SantaCruzIsland_Validation_5Class/ ubuntu@172.16.31.10:~/GPU_Serverless/data

# yq
sudo snap install yq

# Virtualbox

wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list.d/virtualbox.list'

sudo apt update
sudo apt-get -y install gcc make linux-headers-$(uname -r) dkms

sudo apt update
sudo apt-get install virtualbox-5.2

# minkube

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube

sudo mkdir -p /usr/local/bin/
sudo install minikube /usr/local/bin/

minikube config set memory 4096
minikube config set cpus 2
# minikube config set disk 40000
minikube config set vm-driver virtualbox

# kubeless namespace

export RELEASE=$(curl -s https://api.github.com/repos/kubeless/kubeless/releases/latest | grep tag_name | cut -d '"' -f 4)
kubectl create ns kubeless

kubectl create -f minikube/deploy_edge.yaml

# Docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
apt-cache policy docker-ce

sudo apt-get install -y docker-ce
sudo systemctl status docker

# Make docker to interact with minikube
eval $(minikube docker-env)

# Nautilus Credentials
# scp service-account and mv to nautilus in .kube

export KUBECONFIG=~/.kube/config:~/.kube/nautilus
kubectx nautilus
kubectx minikube

# Create pv & pvc & transfer_pod
kubectl create -f minikube/pvc.yaml
kubectl create -f minikube/transfer_pod.yaml

# Copy image & model to persistent volume
kubectl cp ~/GPU_Serverless/data/SantaCruzIsland_Labeled_5Class default/transfer-pod:/racelab/
kubectl cp ~/GPU_Serverless/data/SantaCruzIsland_Validation_5Class default/transfer-pod:/racelab/
kubectl cp ~/GPU_Serverless/checkpoints/ default/transfer-pod:/racelab/checkpoints

# Create and Patch image-clf-inf deployment
sh scripts/deploy.sh image-clf-inf 3.6 0 _edge
# kubectl patch deployment image-clf-inf --patch "$(cat ./scripts/patch_edge.yaml)"

# Initialize DB tables
cd STOIC
go build
sh StartDBinit.sh

# Start Client
sh StartClient.sh

# Add the service account to rolebinding for namespace admin and kubeless role
kubectl edit rolebinding nautilus-admin
kubectl edit rolebinding kubeless

- kind: ServiceAccount
  name: admin-user
  namespace: racelab

pip install pymysql sklearn


<reponame>travis-val/cairo-windows
#! bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT

# Versions used
USE_FREETYPE=1
CAIRO_VERSION=cairo-1.17.4
PIXMAN_VERSION=pixman-0.40.0
LIBPNG_VERSION=libpng-1.6.37
ZLIB_VERSION=zlib-1.2.11
FREETYPE_VERSION=freetype-2.10.2

# Set variables according to command line argument
if [ ${1:-x86} = x64 ] || [ ${2:-x86} = x64 ]; then
    MSVC_PLATFORM_NAME=x64
    OUTPUT_PLATFORM_NAME=x64
else
    MSVC_PLATFORM_NAME=Win32
    OUTPUT_PLATFORM_NAME=x86
fi

if [ ${1:-Release} = Debug ] || [ ${2:-Release} = Debug ]; then
    CONFIG_LABEL=Debug
    CONFIG=debug
else
    CONFIG_LABEL=Release
    CONFIG=release
fi

# Make sure the MSVC linker appears first in the path
MSVC_LINK_PATH=`whereis link | sed "s| /usr/bin/link.exe||" | sed "s|.*\(/c.*\)link.exe.*|\1|"`
export PATH="$MSVC_LINK_PATH:$PATH"

# Download packages if not already
wget -nc https://www.cairographics.org/snapshots/$CAIRO_VERSION.tar.xz
wget -nc https://www.cairographics.org/releases/$PIXMAN_VERSION.tar.gz
wget -nc https://download.sourceforge.net/libpng/$LIBPNG_VERSION.tar.gz
wget -nc http://www.zlib.net/$ZLIB_VERSION.tar.gz
if [ $USE_FREETYPE -ne 0 ]; then
    wget -nc http://download.savannah.gnu.org/releases/freetype/$FREETYPE_VERSION.tar.gz
fi

# Extract packages if not already
if [ ! -d cairo ]; then
    echo "Extracting $CAIRO_VERSION..."
    tar -xJf $CAIRO_VERSION.tar.xz
    mv $CAIRO_VERSION cairo
fi
if [ ! -d pixman ]; then
    echo "Extracting $PIXMAN_VERSION..."
    tar -xzf $PIXMAN_VERSION.tar.gz
    mv $PIXMAN_VERSION pixman
fi
if [ ! -d libpng ]; then
    echo "Extracting $LIBPNG_VERSION..."
    tar -xzf $LIBPNG_VERSION.tar.gz
    mv $LIBPNG_VERSION libpng
fi
if [ ! -d zlib ]; then
    echo "Extracting $ZLIB_VERSION..."
    tar -xzf $ZLIB_VERSION.tar.gz
    mv $ZLIB_VERSION zlib
fi
if [ $USE_FREETYPE -ne 0 ] && [ ! -d freetype ]; then
    echo "Extracting $FREETYPE_VERSION..."
    tar -xzf $FREETYPE_VERSION.tar.gz
    mv $FREETYPE_VERSION freetype
fi

# Build libpng and zlib
cd libpng
sed 's#4996</Disable#4996;5045;4061</Disable#' projects/vstudio/zlib.props > zlib.props.fixed
mv zlib.props.fixed projects/vstudio/zlib.props
if [ ! -d "projects\vstudio\Backup" ]; then
    # Upgrade solution if not already
    devenv.com "projects\vstudio\vstudio.sln" -upgrade
fi
devenv.com "projects\vstudio\vstudio.sln" -build "$CONFIG_LABEL Library|$MSVC_PLATFORM_NAME" -project libpng
cd ..
if [ $MSVC_PLATFORM_NAME = x64 ]; then
    cp "libpng/projects/vstudio/x64/$CONFIG_LABEL Library/libpng16.lib" libpng/libpng.lib
    cp "libpng/projects/vstudio/x64/$CONFIG_LABEL Library/zlib.lib" zlib/zlib.lib
else
    cp "libpng/projects/vstudio/$CONFIG_LABEL Library/libpng16.lib" libpng/libpng.lib
    cp "libpng/projects/vstudio/$CONFIG_LABEL Library/zlib.lib" zlib/zlib.lib
fi

# Build pixman
cd pixman
sed s/-MD/-MT/ Makefile.win32.common > Makefile.win32.common.fixed
mv Makefile.win32.common.fixed Makefile.win32.common
if [ $MSVC_PLATFORM_NAME = x64 ]; then
    # pass -B for switching between x86/x64
    make pixman -B -f Makefile.win32 "CFG=$CONFIG" "MMX=off"
else
    make pixman -B -f Makefile.win32 "CFG=$CONFIG"
fi
cd ..

if [ $USE_FREETYPE -ne 0 ]; then
    cd freetype
    # Build freetype
    if [ ! -d "builds/windows/vc2010/Backup" ]; then
        # Upgrade solution if not already
        devenv.com "builds/windows/vc2010/freetype.sln" -upgrade
    fi
    devenv.com "builds/windows/vc2010/freetype.sln" -build "$CONFIG_LABEL Static|$MSVC_PLATFORM_NAME"
    cp "`ls -1d "objs/$MSVC_PLATFORM_NAME/$CONFIG_LABEL Static/freetype.lib"`" .
    cd ..
fi

# Build cairo
cd cairo
sed 's/-MD/-MT/;s/zdll.lib/zlib.lib/' build/Makefile.win32.common > Makefile.win32.common.fixed
mv Makefile.win32.common.fixed build/Makefile.win32.common
if [ $USE_FREETYPE -ne 0 ]; then
    sed '/^CAIRO_LIBS =/s/$/ $(top_builddir)\/..\/freetype\/freetype.lib/;/^DEFAULT_CFLAGS =/s/$/ -I$(top_srcdir)\/..\/freetype\/include/' build/Makefile.win32.common > Makefile.win32.common.fixed
else
    sed '/^CAIRO_LIBS =/s/ $(top_builddir)\/..\/freetype\/freetype.lib//;/^DEFAULT_CFLAGS =/s/ -I$(top_srcdir)\/..\/freetype\/include//' build/Makefile.win32.common > Makefile.win32.common.fixed
fi
mv Makefile.win32.common.fixed build/Makefile.win32.common
sed "s/CAIRO_HAS_FT_FONT=./CAIRO_HAS_FT_FONT=$USE_FREETYPE/" build/Makefile.win32.features > Makefile.win32.features.fixed
mv Makefile.win32.features.fixed build/Makefile.win32.features
# pass -B for switching between x86/x64
make -B -f Makefile.win32 cairo "CFG=$CONFIG"
cd ..

# Package headers with DLL
OUTPUT_FOLDER=output/${CAIRO_VERSION/cairo-/cairo-windows-}/${CONFIG_LABEL}
mkdir -p $OUTPUT_FOLDER/include
for file in cairo/src/cairo-version.h \
            cairo/src/cairo-features.h \
            cairo/src/cairo.h \
            cairo/src/cairo-deprecated.h \
            cairo/src/cairo-win32.h \
            cairo/src/cairo-script.h \
            cairo/src/cairo-ps.h \
            cairo/src/cairo-pdf.h \
            cairo/src/cairo-svg.h; do
    cp $file $OUTPUT_FOLDER/include
done
if [ $USE_FREETYPE -ne 0 ]; then
    cp cairo/src/cairo-ft.h $OUTPUT_FOLDER/include
fi
mkdir -p $OUTPUT_FOLDER/lib/$OUTPUT_PLATFORM_NAME
cp cairo/src/$CONFIG_LABEL/cairo.lib $OUTPUT_FOLDER/lib/$OUTPUT_PLATFORM_NAME
mkdir -p $OUTPUT_FOLDER/bin/$OUTPUT_PLATFORM_NAME
cp cairo/src/$CONFIG_LABEL/cairo.dll $OUTPUT_FOLDER/bin/$OUTPUT_PLATFORM_NAME
cp cairo/COPYING* $OUTPUT_FOLDER

trap - EXIT
echo 'Success!'


#!/usr/bin/env bash

TARGETS="shorewall{,6}"

function info {
	echo "INFO: ${@}"
}

function err {
	>&2 echo "ERROR: ${@}"
}

function apply_lite {
    local __HOST=${1} __TARGET
    info "Processing host" ${__HOST}
    for __TARGET in $(eval echo ${TARGETS})
    do
        info "Applying " ${__TARGET}
        ${__TARGET} remote-restart -c build/${__TARGET} ${__HOST}
    done
}

for TARGET in "${@}"
do
    apply_lite ${TARGET}
done


<filename>tag.sh<gh_stars>100-1000
#!/usr/bin/env bash

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

set -e
set -x

package=$(node -e 'console.log(require("./package.json").name);')
version=$(npm dist-tag ls "$package" | grep '^alpha:' | cut -d ' ' -f2)
tag=${1:-latest}

npm dist-tag add "$package"@"$version" "$tag"


#!/bin/bash
cd ~/Discord-Nitro-Generator-and-Checker/
python3 ./main.py


<reponame>igtm/graphql-scalars
echo "> Start transpiling ES2015"
echo ""
./node_modules/.bin/babel src --ignore __tests__ --out-dir ./dist
echo ""
echo "> Complete transpiling ES2015"


<filename>run-eth-btc.sh<gh_stars>1-10
#!/bin/sh

./zenbot launch map --backfill run --config config_eth_btc.js --rs eth_btc


<reponame>aravindraja93/mesh_com
#!/bin/bash -e

. /enclave/drone_device_id

export DRONE_DEVICE_ID

source /opt/ros/galactic/setup.bash

# I don't know what we're doing wrong, but Python isn't able to resolve mesh packages without this.
# (other Python packages seem to reside under /usr/lib/python3/dist-packages)
export PYTHONPATH=/opt/ros/galactic/lib/python3.8/site-packages

if [ "$1" == "init" ]; then

    echo "Start mesh executor"
    # Start mesh executor
    /opt/ros/galactic/share/bin/mesh-ibss.sh ap
    /opt/ros/galactic/lib/mesh_com/mesh_executor

else
    echo "Start mesh pub&sub"

    mkdir -p ~/.ros/log

    # Start mesh publisher
    ros2 run mesh_com mesh_publisher --ros-args -r __ns:=/$DRONE_DEVICE_ID &
    # Start mesh subscriber
    ros2 run mesh_com mesh_subscriber --ros-args -r __ns:=/$DRONE_DEVICE_ID

fi


<reponame>jishminor/model_analyzer<filename>qa/L0_server_launch_modes/test.sh
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# 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.

source ../common/util.sh

rm -f *.log
OUTPUT_MODEL_REPOSITORY=${OUTPUT_MODEL_REPOSITORY:=`get_output_directory`}
rm -rf $OUTPUT_MODEL_REPOSITORY

# Set test parameters
MODEL_ANALYZER="`which model-analyzer`"
MODEL_REPOSITORY=${MODEL_REPOSITORY:="/mnt/dldata/inferenceserver/model_analyzer_clara_pipelines"}
MODEL_NAMES="classification_chestxray_v1"
BATCH_SIZES="4"
CONCURRENCY="4"
PORTS=(`find_available_ports 3`)
http_port="${PORTS[0]}"
grpc_port="${PORTS[1]}"
metrics_port="${PORTS[2]}"
MODEL_ANALYZER_BASE_ARGS="-m $MODEL_REPOSITORY -n $MODEL_NAMES -b $BATCH_SIZES -c $CONCURRENCY --run-config-search-disable"
MODEL_ANALYZER_BASE_ARGS="$MODEL_ANALYZER_BASE_ARGS --output-model-repository-path $OUTPUT_MODEL_REPOSITORY"
MODEL_ANALYZER_PORTS="--triton-http-endpoint localhost:$http_port --triton-grpc-endpoint localhost:$grpc_port"
MODEL_ANALYZER_PORTS="$MODEL_ANALYZER_PROTS --triton-metrics-url http://localhost:$metrics_port/metrics"
TRITON_LAUNCH_MODES="docker remote local"
TRITON_SERVER_VERSION="21.02-py3"
CLIENT_PROTOCOLS="http grpc"

# Run the model-analyzer, both client protocols
RET=0

function check_all_gpus() {
    analyzer_gpus=($@)
    gpu_uuids=(`get_all_gpus_uuids`)
    cuda_devices=(`echo $CUDA_VISIBLE_DEVICES | sed "s/,/ /g"`)

    if [ ${#analyzer_gpus[@]} != ${#cuda_devices[@]} ]; then
        return 1
    fi

    index=0
    for cuda_index in $cuda_devices; do
        gpu_uuid=${gpu_uuids[$cuda_index]}
        if [ $gpu_uuid != ${analyzer_gpus[$index]} ]; then
            echo -e "\n***\n*** Model Analyzer is not using the correct GPUs.\n***"
            return 1
        fi
        index=$((index+1))
    done
    return 0
}

function check_gpus() {
    analyzer_gpus=($1)
    triton_gpus=($2)

    if [ ${#analyzer_gpus[@]} != ${#triton_gpus[@]} ]; then
        return 1
    fi

    index=0
    for analyzer_gpu in $analyzer_gpus; do
        gpu_uuid=${triton_gpus[$index]}
        if [ $gpu_uuid != $analyzer_gpu ]; then
            echo -e "\n***\n*** Model Analyzer is not using the correct GPUs.\n***"
            return 1
        fi
        index=$((index+1))
    done
    return 0
}

function convert_gpu_array_to_flag() {
    gpu_array=$1
    if [ ${#gpu_array[@]} -ge 1 ]; then
        gpus_flag="--gpus "
        for gpu in ${gpu_array[@]}; do
            gpus_flag="$gpu_flag $gpu,"
        done

        # Remove trailing comma
        gpu_flag=${gpu_flag::-1}
        echo $gpu_flag
    else
        echo ""
    fi
}

function run_server_launch_modes() {
    gpus=$1
    for PROTOCOL in $CLIENT_PROTOCOLS; do
        MODEL_ANALYZER_ARGS_WITH_PROTOCOL="$MODEL_ANALYZER_BASE_ARGS --client-protocol=$PROTOCOL `convert_gpu_array_to_flag $gpus`"
        for LAUNCH_MODE in $TRITON_LAUNCH_MODES; do
            rm -rf $OUTPUT_MODEL_REPOSITORY
            MODEL_ANALYZER_ARGS_WITH_LAUNCH_MODE="$MODEL_ANALYZER_ARGS_WITH_PROTOCOL --triton-launch-mode=$LAUNCH_MODE"
            ANALYZER_LOG=analyzer.${LAUNCH_MODE}.${PROTOCOL}.log
            SERVER_LOG=${LAUNCH_MODE}.${PROTOCOL}.server.log

            # Set arguments for various launch modes
            if [ "$LAUNCH_MODE" == "local" ]; then
                MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS_WITH_LAUNCH_MODE $MODEL_ANALYZER_PORTS --triton-output-path=${SERVER_LOG}"
            elif [ "$LAUNCH_MODE" == "docker" ]; then
                MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS_WITH_LAUNCH_MODE --triton-version=$TRITON_SERVER_VERSION $MODEL_ANALYZER_PORTS --triton-output-path=${SERVER_LOG}"
            elif [ "$LAUNCH_MODE" == "remote" ]; then
                MODEL_ANALYZER_PORTS="--triton-http-endpoint localhost:8000 --triton-grpc-endpoint localhost:8001"
                MODEL_ANALYZER_PORTS="$MODEL_ANALYZER_PROTS --triton-metrics-url http://localhost:8002/metrics"
                MODEL_ANALYZER_ARGS="$MODEL_ANALYZER_ARGS_WITH_LAUNCH_MODE $MODEL_ANALYZER_PORTS"

                # For remote launch, set server args and start server
                SERVER=`which tritonserver`
                SERVER_ARGS="--model-repository=$MODEL_REPOSITORY --model-control-mode=explicit"

                run_server
                if [ "$SERVER_PID" == "0" ]; then
                    echo -e "\n***\n*** Failed to start $SERVER\n***"
                    cat $SERVER_LOG
                    exit 1
                fi
            fi

            # Run the analyzer and check the results
            set +e
            run_analyzer
            if [ $? -ne 0 ]; then
                echo -e "\n***\n*** Test with launch mode '${LAUNCH_MODE}' using ${PROTOCOL} client Failed."\
                        "\n***     model-analyzer exited with non-zero exit code. \n***"
                cat $ANALYZER_LOG
                RET=1
            fi
            set -e

            if [ "$LAUNCH_MODE" == "remote" ]; then
                kill $SERVER_PID
                wait $SERVER_PID
            else
                if [ ! -s "$SERVER_LOG" ]; then
                    echo -e "\n***\n*** Test Output Verification Failed : No logs found\n***"
                    cat $ANALYZER_LOG
                    RET=1
                fi
            fi

            model_analyzer_gpu_uuids=`cat $ANALYZER_LOG | grep -E "Using GPU\(s\) with UUID\(s\)" | tail -n 1 | sed -n 's/.*{\(.*\)}.*/\1/p'`
            model_analyzer_gpu_uuids=(`echo $model_analyzer_gpu_uuids | sed "s/,/ /g"`)
            if [ -z $gpus ]; then
                check_all_gpus "${model_analyzer_gpu_uuids[@]}"
            else
                check_gpus "${model_analyzer_gpu_uuids[@]}" "${gpus[@]}"
            fi
            if [ $? -ne 0 ]; then
                RET=1
                break
            fi
        done
    done
}

# This test will be executed with 4-GPUs.
CUDA_DEVICE_ORDER="PCI_BUS_ID"

##########################################################
# Test controling the GPUs with the CUDA_VISIBLE_DEVICES #
##########################################################
export CUDA_VISIBLE_DEVICES=3
run_server_launch_modes

export CUDA_VISIBLE_DEVICES=1,2
run_server_launch_modes

export CUDA_VISIBLE_DEVICES=0,1,2
run_server_launch_modes

#################################################
# Test controling the GPUs with the --gpus flag #
#################################################
CURRENT_GPUS=(${GPUS[2]})
run_server_launch_modes "$CURRENT_GPUS"

CURRENT_GPUS=(${GPUS[2]})
run_server_launch_modes "$CURRENT_GPUS"

CURRENT_GPUS=${GPUS[@]:1}
run_server_launch_modes "$CURRENT_GPUS"

CURRENT_GPUS=${GPUS[@]:1}
run_server_launch_modes "$CURRENT_GPUS"

if [ $RET -eq 0 ]; then
    echo -e "\n***\n*** Test PASSED\n***"
else
    echo -e "\n***\n*** Test FAILED\n***"
fi

exit $RET


<reponame>go-orit/kidsrubyinstaller-osx
#!/bin/sh
VERSION=$1

cleanup() {
	if [ -d "build/KidsRuby.app" ]
	then
		rm -r "build/KidsRuby.app"
	fi
	if [ -d "resources/KidsRuby.app" ]
	then
		rm -r "resources/KidsRuby.app"
	fi
  if [ -d "resources/i18n" ]
	then
		rm -r "resources/i18n"
	fi
	if [ -d "build/KidsRubyInstaller.app" ]
	then
		rm -r "build/KidsRubyInstaller.app"
	fi
	if [ -d "build/KidsRubyInstaller.app.dmg" ]
	then
		rm -r "build/KidsRubyInstaller.app.dmg"
	fi
}

build_launcher() {
	cd build
	../appify.sh ../kidsruby.sh "KidsRuby"
	../assignIcon.py ../kidsrubylogo.png KidsRuby.app
	tar cvzf "KidsRuby.app.tar.gz" KidsRuby.app
	cd ..
	mv build/KidsRuby.app.tar.gz resources
}

copy_scripts() {
	cp install_gems.sh resources
	cp kidsirb.sh resources
}

copy_i18n() {
  mkdir resources/i18n
  cp i18n/* resources/i18n
}

build_installer() {
	/usr/local/bin/platypus -AR  -l -i 'kidsruby.icns' -a "KidsRuby $VERSION Installer for OSX" -o 'Progress Bar' -p '/bin/sh' -u 'The Hybrid Group + Friends'  -V "$1"  -I 'org.kidsruby.installer' -f 'resources/git-1.7.6-i386-snow-leopard.dmg' -f 'resources/ruby-1.9.2-p320.universal.tar.gz' -f 'resources/yaml-0.1.4.universal.tar.gz' -f 'resources/qt-mac-opensource-4.7.3.dmg' -f 'resources/qtbindings-4.7.3-universal-darwin-10.gem' -f 'resources/kidsruby.tar.gz' -f 'resources/kidsirb.sh' -f 'resources/KidsRuby.app.tar.gz' -f "resources/gosu-0.7.36.2-universal-darwin.gem" -f "resources/htmlentities-4.3.0.gem" -f "resources/rubywarrior-i18n-0.0.3.gem" -f "resources/serialport-1.1.1-universal.x86_64-darwin-10.gem" -f "resources/hybridgroup-sphero-1.0.1.gem" -f "resources/install_gems.sh" -f "resources/i18n/en.sh" -g '#000000'  -b '#ffffff'  -c 'installer.sh' 'build/KidsRubyInstaller.app'
}

build_dmg() {
	cd build
	../makedmg KidsRubyInstaller.app
	mv KidsRubyInstaller.app.dmg kidsrubyinstaller-$VERSION.dmg
	cd ..
}

cleanup
build_launcher
copy_scripts
copy_i18n
build_installer
build_dmg


<reponame>TheCynosure/CynOS<filename>debug.sh
./build.sh -g
./setupDebug.sh
./launchDebug.sh


<reponame>AlienSarlak/mason
#!/usr/bin/env bash

set -ue

: '
Assumes gdal and postgis have been linked

'

if [[ ${PGDATA:-unset} != "unset" ]] || [[ ${PGHOST:-unset} != "unset" ]] || [[ ${PGTEMP_DIR:-unset} != "unset" ]]; then
    echo "ERROR: this script deletes \${PGDATA}, \${PGHOST}, and \${PGTEMP_DIR}."
    echo "So it will not run if you have these set in your environment"
    exit 1
fi

# make sure we can init, start, create db, and stop
export PGDATA=./local-postgres
# PGHOST must start with / so therefore must be absolute path
export PGHOST=$(pwd)/local-unix-socket
export PGTEMP_DIR=$(pwd)/local-tmp
export PGPORT=1111

# cleanup
function cleanup() {
    if [[ -d ${PGDATA} ]]; then rm -r ${PGDATA}; fi
    if [[ -d ${PGTEMP_DIR} ]]; then rm -r ${PGTEMP_DIR}; fi
    if [[ -d ${PGHOST} ]]; then rm -r ${PGHOST}; fi
    rm -f postgres.log
    rm -f seattle_washington_water_coast*
    rm -f seattle_washington.water.coast*
}

function setup() {
    mkdir ${PGTEMP_DIR}
    mkdir ${PGHOST}
}

function finish {
  ./mason_packages/.link/bin/pg_ctl -w stop
  cleanup
}

trap finish EXIT

cleanup
setup

./mason_packages/.link/bin/initdb
export PATH=./mason_packages/.link/bin/:${PATH}
# must be absolute
export GDAL_DATA=$(pwd)/mason_packages/.link/share/gdal
postgres -k $PGHOST > postgres.log &
sleep 2
cat postgres.log
createdb template_postgis
psql -l
psql template_postgis -c "CREATE TABLESPACE temp_disk LOCATION '${PGTEMP_DIR}';"
psql template_postgis -c "SET temp_tablespaces TO 'temp_disk';"
psql template_postgis -c "CREATE EXTENSION postgis;"
psql template_postgis -c "SELECT PostGIS_Full_Version();"
curl -OL "https://s3.amazonaws.com/metro-extracts.mapzen.com/seattle_washington.water.coastline.zip"
unzip -o seattle_washington.water.coastline.zip
createdb test-osm -T template_postgis
shp2pgsql -s 4326 seattle_washington_water_coast.shp coast | psql test-osm
psql test-osm -c "SELECT count(*) from coast;"


#!/bin/bash

#pHAT DAC (removes default audio)
if [[ "$PHAT_DAC" = "1" ]]; then
  rmmod snd_bcm2835 || true
fi

# Handle Kodi userdata folder, /data is a permanent folder between containers
mkdir /data/kodi >/dev/null 2>&1 || true && rm -rf /root/.kodi && ln -s /data/kodi /root/.kodi
mkdir /data/Pictures >/dev/null 2>&1 || true
# cp /usr/src/app/test.jpg /data/Pictures

cp /usr/src/app/autoexec.py /data/kodi/userdata
cp /usr/src/app/guisettings.xml /data/kodi/userdata/

# Move plugin.dbmc
mkdir /data/kodi/addons/plugin.dbmc >/dev/null 2>&1 || true
cp -r /usr/src/app/plugin.dbmc/* /data/kodi/addons/plugin.dbmc

mkdir /data/kodi/userdata/addon_data/plugin.dbmc >/dev/null 2>&1 || true
cp -r /usr/src/app/plugin.dbmc.addon_data/* /data/kodi/userdata/addon_data/plugin.dbmc

# Move script.service.kodi.callbacks
mkdir /data/kodi/addons/script.service.kodi.callbacks >/dev/null 2>&1 || true
cp -r /usr/src/app/script.service.kodi.callbacks/* /data/kodi/addons/script.service.kodi.callbacks

mkdir /data/kodi/userdata/addon_data/script.service.kodi.callbacks >/dev/null 2>&1 || true
cp -r /usr/src/app/script.service.kodi.callbacks.addon_data/* /data/kodi/userdata/addon_data/script.service.kodi.callbacks

# Use sed here to insert environment var with plugin token
echo "Using Dropbox: $DBX_FOLDER"
sed -i "36s|.*V/.*|V/$DBX_FOLDER|" '/data/kodi/userdata/addon_data/plugin.dbmc/accounts/Superliminal Dropbox/settings'

echo "Display effects: $EFFECTS"

echo "TEST: $RESIN_HOST_CONFIG_gpu_mem"

# Insert slideshow stay time
sed -i "s|.*<staytime.*|<staytime default='true'>$STAYTIME</staytime>|" '/data/kodi/userdata/guisettings.xml'
sed -i "s|.*<webserver.*|<webserver>$WEBSRV</webserver>|" '/data/kodi/userdata/guisettings.xml'
sed -i "s|.*<webserverpassword.*|<webserverpassword>$WEB_PASS</webserverpassword>|" '/data/kodi/userdata/guisettings.xml'
sed -i "s|.*<webserverusername.*|<webserverusername>$WEB_USR</webserverusername>|" '/data/kodi/userdata/guisettings.xml'
sed -i "s|.*<webserverport.*|<webserverport default='true'>$WEB_PORT</webserverport>|" '/data/kodi/userdata/guisettings.xml'
sed -i "s|.*<shuffle.*|<shuffle>$SHUFFLE</shuffle>|" '/data/kodi/userdata/guisettings.xml'
sed -i "s|.*<displayeffects.*|<displayeffects default='false'>$EFFECTS</displayeffects>|" '/data/kodi/userdata/guisettings.xml'

# python /usr/src/app/startup.py #Only handles USB

# ln -s /data/kodi/addons/plugin.dbmc /usr/share/kodi/addons/plugin.dbmc
# ln -s /data/kodi/addons/script.service.kodi.callbacks /usr/share/kodi/addons/script.service.kodi.callbacks
cp /usr/src/app/addon-manifest.xml /usr/share/kodi/system

while true; do
    DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host_run/dbus/system_bus_socket /usr/bin/kodi-standalone
done


mvn org.apache.maven.plugins:maven-dependency-plugin:2.7:copy-dependencies -DoutputDirectory=dependencies


#!/usr/bin/env bash

SRC_API_QEUEUE="../api"

APIS_OUT="src/main/java/"

APIS_OUT_QUEUE="queue/$APIS_OUT"

protoc -I../ $SRC_API_QEUEUE/*.proto --java_out=$APIS_OUT_QUEUE --grpc-java_out=$APIS_OUT_QUEUE --plugin=protoc-gen-grpc-java=$GOPATH/bin/protoc-gen-grpc-java


#!/bin/bash

echo "Downloading hydra..."
curl -L "https://github.com/Shravan-1908/hydra/releases/latest/download/hydra-linux-amd64" -o hydra

echo "Adding hydra into PATH..."

mkdir -p ~/.hydra

chmod u+x ./hydra

mv ./hydra ~/.hydra
echo "export PATH=$PATH:~/.hydra" >> ~/.bashrc
set -U fish_user_paths ~/.hydra/ $fish_user_paths
echo "export PATH=$PATH:~/.hydra" >> ~/.zshrc

echo "hydra installation is completed!"
echo "You need to restart the shell to use hydra."


<reponame>abhijith0505/Scripts
#!/bin/sh

USN="1mv14cs085"
url="http://results.vtu.ac.in/results17/result_page.php?usn=$USN"	#Change this if VTU changes the result url
html_file="output.html"
res="non_empty_string"

#Result size not zero
while [ -n "$res" ]; do
	echo "`date +%r` : Retrying..."
	curl --silent --max-time 10 $url > $html_file	#Try for 10 seconds

	#Result of last operation was successful (Did not time out)
	if [ $? -eq 0 ]; then
		#Checks if output contains the 'unavailable' message
		res=`grep 'University Seat Number is not available or Invalid' $html_file`
	fi
done

#Opens the saved result with firefox
firefox $html_file &

#Plays an alert sound 30 times (Please ensure speaker volume is high)
count=30
while [ $count -gt 0 ]
do
	paplay --volume=65536 beep.wav
	((count--))
done


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

UNIQUE_RESOURCE_VERSION=dev
PROTOZERO_VERSION=1.3.0
BOOST_VERSION=1.60.0
BOOST_LIBPROGRAM_OPTIONS_VERSION=1.60.0
GLFW_VERSION=3.1.2
SQLITE_VERSION=3.9.1
ZLIB_VERSION=system
NUNICODE_VERSION=1.6
GEOMETRY_VERSION=0.8.0
GEOJSON_VERSION=0.1.4
GEOJSONVT_VERSION=6.1.2
SUPERCLUSTER_VERSION=0.2.0
KDBUSH_VERSION=0.1.1
VARIANT_VERSION=1.1.0
RAPIDJSON_VERSION=1.0.2
GTEST_VERSION=1.7.0
PIXELMATCH_VERSION=0.9.0
EARCUT_VERSION=0.11
BENCHMARK_VERSION=1.0.0


n=1

while [ $n -le 5 ]
do
    echo "$n"
    n=`expr $n + 1`
done

echo "============================"

while [ $n -le 10 ]
do
    echo "$n"
    n=$(( n+1 ))
done

echo "============================"

while (( $n <= 15 ))
do
    echo "$n"
    (( n++ ))
done


#! /bin/bash
APPLICATION=$1
STACK=$2
REGION=${3:-us-east-1}

S3BUCKETNAME=cf-deployment-${APPLICATION}-${REGION}
PARAMETERFILE=./parameters/${STACK}.json
TEMPLATEFILE=./${STACK}.yml

PARAMETERS=$(jq -r '.[] | [.ParameterKey, .ParameterValue] | "\(.[0])=\(.[1])"' ${PARAMETERFILE})

if aws s3 ls "s3://${S3BUCKETNAME}" 2>&1 | grep -q 'NoSuchBucket'; then
    echo "creating deployment bucket ${S3BUCKETNAME}"
    aws s3 mb s3://${S3BUCKETNAME}
else
    echo "deployment bucket ${S3BUCKETNAME} already exists"
fi

aws cloudformation deploy \
    --template-file ${TEMPLATEFILE} \
    --stack-name ${APPLICATION}-${STACK}-stack \
    --s3-bucket ${S3BUCKETNAME} \
    --s3-prefix ${STACK} \
    --parameter-overrides ${PARAMETERS} \
    --capabilities CAPABILITY_NAMED_IAM \
    --region ${REGION}


# Brew
alias brwe="brew"
alias bsl="brew services list"


<gh_stars>0
#!/bin/bash
#
# compile an Oberon module <M>.c into a shared library lib<outname>.so
# or, if the option -m is specified, into an executable file <outname>
#
# SYNOPSIS
#   cl.bash moduleName outname options ccOptions

if [ -z "$1" ]; then
  echo "Compile an Oberon module <M>.c into a shared library lib<outname>.so"
  echo "or, if the option -m is specified, into an executable file <outname>."
  echo "ccOptions must be enclosed in quotes."
  echo
  echo "Usage: $0 moduleName outname options ccOptions"
  echo "options = -mgO   where m is for main, g for debug and O for optimze"
  echo
  echo "Examples:"
  echo "  " $0 MyModule Oberon_MyModule -g "\""-g -Lmypath -lOberon_MyImport1"\""
  echo "  " $0 MyMainModule Main -g "\""-g -Lmypath -lOberon_MyImport1"\"" -m
else
  if [[ $3 =~ .*m.* ]]; then
    # compile and link <M>.c into executable
    rm -f $2
    cc $1.c -I$OFRONT_HOME/V4_ofront -g -o $2 -L. -L$OFRONT_HOME/lib $4
  else
    # compile and link <M>.c into shared library lib<M>.so
    rm -f lib$2.so
    cc $1.c -I$OFRONT_HOME/V4_ofront -g -shared -o lib$2.so -L. -L$OFRONT_HOME/lib $4
  fi
fi


#!/bin/sh

# build-moxiebox-tools.sh
#
# Copyright (c) 2014  <NAME>
#
# The above named program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# The above named program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this work; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301, USA.

# A basic script to build the moxiebox toolchain.  It requires that the
# GNU src & gcc trees be checked out in the current directory.

MAKEJOBS=4

if ! test -f src/src-release; then
  echo "ERROR: missing GNU src tree (i.e., newlib and libgloss)."
  exit 1
fi

if ! test -f binutils-gdb/src-release*; then
  echo "ERROR: missing binutils-gdb tree."
  exit 1
fi

if ! test -f gcc/gcc/version.h; then
  echo "ERROR: missing GNU gcc tree."
  exit 1
fi

for dir in buildmoxiebox/gcc-boot buildmoxiebox/gcc buildmoxiebox/binutils-gdb buildmoxiebox/src root/usr; do
  if ! test -d $dir; then
    mkdir -p $dir;
  fi;
done;

PREFIX=`(cd root/usr; pwd)`

(cd buildmoxiebox/binutils-gdb;
  ../../binutils-gdb/configure --target=moxiebox \
      --disable-gdbtk \
      --prefix=$PREFIX;
  make -j$MAKEJOBS all-binutils all-gas all-ld;
  make install-binutils install-gas install-ld)

(cd buildmoxiebox/gcc-boot;
  ../../gcc/configure  --target=moxiebox \
                       --prefix=$PREFIX \
                       --enable-languages=c \
                       --disable-libssp \
                       --disable-libquadmath \
                       --without-newlib;
  make -j$MAKEJOBS all;
  make install)

# Put our new tools on the PATH
PATH=$PREFIX/bin:$PATH

(cd buildmoxiebox/src;
  ../../src/configure --target=moxiebox --prefix=$PREFIX;
  make -j$MAKEJOBS all-target-newlib all-target-libgloss \
      CC_FOR_TARGET=moxiebox-gcc;
  make install-target-newlib install-target-libgloss \
      CC_FOR_TARGET=moxiebox-gcc;)

(cd buildmoxiebox/gcc;
  ../../gcc/configure  --target=moxiebox \
                       --prefix=`(cd ../../root/usr; pwd)` \
                       --enable-languages=c,c++ \
                       --disable-libssp \
                       --disable-libquadmath \
                       --with-newlib \
                       --with-headers=$PREFIX/moxiebox/include;
  make -j$MAKEJOBS all;
  make install)

#(cd buildmoxiebox/binutils-gdb;
#  make -j$MAKEJOBS all-gdb;
#  make install-gdb)

if ! test -f root/usr/moxiebox/lib/crt0.o; then
  (cd root/usr/moxiebox/lib; ln -s ../../../../../runtime/crt0.o .)
fi

if ! test -f root/usr/moxiebox/lib/libsandboxrt.a; then
  (cd root/usr/moxiebox/lib; ln -s ../../../../../runtime/libsandboxrt.a .)
fi


<filename>.ci/publish_gcloud.sh
BRANCH=$1
gsutil cp -r dist/* "gs://cdn.terminusdb.com/js_libs/terminusdb-react-components/${BRANCH}/"


#!/bin/bash

make CXX="${CXX}" CXXFLAGS="${CXXFLAGS}"

mkdir -p "${PREFIX}/bin"
cp paraclu "${PREFIX}/bin/"
sed -i -e '1s,^#! */bin/sh,#!/bin/bash,' paraclu-cut.sh
cp paraclu-cut.sh "${PREFIX}/bin/paraclu-cut"


<reponame>cundd/dup<gh_stars>0
# --------------------------------------------------------
# Webserver/Apache methods
# --------------------------------------------------------

# Returns the vhost document root for the host VM
function dupcli::_webserver::get_host_vhost_document_root() {
    if [ ! -z ${DUP_VHOST_DOCUMENT_ROOT+x} ]; then
        echo $DUP_VHOST_DOCUMENT_ROOT;
    else
        echo "$(dirname "$0")/../httpdocs";
    fi
}

# Returns the vhost document root for the guest VM
function dupcli::_webserver::get_guest_vhost_document_root() {
    if [ ! -z ${DUP_VHOST_DOCUMENT_ROOT+x} ]; then
        echo $DUP_VHOST_DOCUMENT_ROOT;
    else
        duplib::get_vhost_document_root;
    fi
}

# Returns the vhost document root
function dupcli::_webserver::get_vhost_document_root() {
    if [[ $(dupcli::is_guest) == "yes" ]]; then
        dupcli::_webserver::get_guest_vhost_document_root;
    else
        dupcli::_webserver::get_host_vhost_document_root;
    fi
}


#!/bin/bash

ACTION=$1
STACK="capstone-project-network"
TEMPLATE="${PWD}/infra/jenkins/network.yaml"
PARAMS="${PWD}/infra/jenkins/parameters.json"

${PWD}/infra/jenkins/run.sh $ACTION $STACK $TEMPLATE $PARAMS


<filename>gpac-0.7.1/tests/make_tests.sh<gh_stars>0
#!/bin/bash

#for user doc, check scripts/00-template

base_args=""

GNU_TIME=/usr/bin/time
GNU_DATE=date
GNU_TIMEOUT=timeout
#GNU_SED=sed
DIFF=diff
GCOV=gcov
FFMPEG=ffmpeg
READLINK=readlink

EXTERNAL_MEDIA_AVAILABLE=1

platform=`uname -s`

if [ $platform = "Darwin" ] ; then
GNU_TIME=gtime
GNU_DATE=gdate
GNU_TIMEOUT=gtimeout
READLINK=greadlink
fi

#if the script in launched from elsewhere, main_dir still needs to be the script directory
main_dir="$(dirname $($READLINK -f $0))"
cd $main_dir

#if launched from an absolute path, set all paths as absolute (will break on cygwin)
rel_main_dir="."
if [[ "$0" = /* ]]; then
  rel_main_dir=$main_dir
fi

MP4CLIENT_NOT_FOUND=0

generate_hash=0
play_all=0
global_test_ui=0
log_after_fail=0
verbose=0
enable_timeout=0
enable_fuzzing=0
fuzz_all=0
fuzz_duration=60
no_fuzz_cleanup=0

current_script=""

DEF_DUMP_DUR=10
DEF_DUMP_SIZE="200x200"
DEF_TIMEOUT=20

#remote location of resource files: all media files, hash files and generated videos
REFERENCE_DIR="http://download.tsi.telecom-paristech.fr/gpac/gpac_test_suite/resources"
#dir where all external media are stored
EXTERNAL_MEDIA_DIR="$rel_main_dir/external_media"
#dir where all hashes are stored
HASH_DIR="$rel_main_dir/hash_refs"
#dir where all specific test rules (override of defaults, positive tests, ...) are stored
RULES_DIR="$rel_main_dir/rules"
#dir where all referenced videos are stored
SCRIPTS_DIR="$rel_main_dir/scripts"
#dir where all referenced videos are stored
VIDEO_DIR_REF="$rel_main_dir/external_videos_refs"

#dir where all local media data (ie from git repo) is stored
MEDIA_DIR="$rel_main_dir/media"
#local dir where all data will be generated (except hashes and referenced videos)
LOCAL_OUT_DIR="$rel_main_dir/results"

#dir where all test videos are generated
VIDEO_DIR="$LOCAL_OUT_DIR/videos"
#dir where all logs are generated
LOGS_DIR="$LOCAL_OUT_DIR/logs"
#temp dir for any test
TEMP_DIR="$LOCAL_OUT_DIR/temp"

ALL_REPORTS="$LOCAL_OUT_DIR/all_results.xml"
ALL_LOGS="$LOCAL_OUT_DIR/all_logs.txt"

TEST_ERR_FILE="$TEMP_DIR/err_exit"

rm -f "$TEST_ERR_FILE" 2> /dev/null
rm -f "$LOGS_DIR/*.sh" 2> /dev/null

if [ ! -e $LOCAL_OUT_DIR ] ; then
mkdir $LOCAL_OUT_DIR
fi

if [ ! -e $HASH_DIR ] ; then
mkdir $HASH_DIR
fi

if [ ! -e $VIDEO_DIR ] ; then
mkdir $VIDEO_DIR
fi

if [ ! -e $VIDEO_DIR_REF ] ; then
mkdir $VIDEO_DIR_REF
fi

if [ ! -e $LOGS_DIR ] ; then
mkdir $LOGS_DIR
fi

if [ ! -e $RULES_DIR ] ; then
mkdir $RULES_DIR
fi

if [ ! -e $TEMP_DIR ] ; then
mkdir $TEMP_DIR
fi

L_ERR=1
L_WAR=2
L_INF=3
L_DEB=4

log()
{
 if [ $TERM = "cygwin" ]; then

  if [ $1 = $L_ERR ]; then
    echo -ne "\033[31m"
  elif [ $1 = $L_WAR ]; then
    echo -ne "\033[32m"
  elif [ $1 = $L_INF ]; then
    echo -ne "\033[34m"
  elif [ $verbose = 0 ]; then
    echo -ne "\033[0m"
    return
  fi

  echo $2
  echo -ne "\033[0m"

 else

  if [ $1 = $L_ERR ]; then
    tput setaf 1
  elif [ $1 = $L_WAR ]; then
    tput setaf 2
  elif [ $1 = $L_INF ]; then
    tput setaf 4
  elif [ $verbose = 0 ]; then
    tput sgr0
    return
  fi

  echo $2
  tput sgr0

 fi
}

print_usage ()
{
echo "GPAC Test Suite Usage: use either one of this command or no command at all"
echo "*** Test suite validation options"
echo "  -clean [ARG]:          removes all removes all results (logs, stat cache and video). If ARG is specified, only clean tests generated by script ARG."
echo "  -play-all:             force playback of BT and XMT files for BIFS (by default only MP4)."
echo "  -no-hash:              runs test suite without hash checking."
echo ""
echo "*** Test suite generation options"
echo "  -clean-hash [ARG]:     removes all generated hash, logs, stat cache and videos. If ARG is specified, only clean tests generated by script ARG."
echo "  -hash:                 regenerate tests with missing hash files."
echo "  -uirec:                generates UI event traces."
echo "  -uiplay:               replays all recorded UI event traces."
echo "  -speed=N:              sets playback speed for -uiplay. Default is 1."
echo ""
echo "*** Fuzzing options"
echo "  -do-fuzz:              runs test using afl-fuzz (gpac has to be compiled with afl-gcc first)."
echo "  -fuzzdur=D:            runs fuzz tests for D (default is $fuzz_duration seconds). D is passed as is to timout program."
echo "  -fuzzall:              fuzz all tests."
echo "  -keepfuzz:             keeps all fuzzing data."
echo ""
echo "*** General options"
echo "  -strict:               stops at the first failed test"
echo "  -warn:                 dump logs after each failed test (used for travisCI)"
echo "  -keep-avi:             keeps raw AVI files (warning this can be pretty big)"
echo "  -keep-tmp:             keeps tmp folder used in tests (erased by default)"
echo "  -sync-hash:            syncs all remote reference hashes with local base"
echo "  -sync-media:           syncs all remote media with local base (warning this can be long)"
echo "  -sync-refs:            syncs all remote reference videos with local base (warning this can be long)"
echo "  -sync-before:          syncs all remote resources with local base (warning this can be long) before running the tests"
echo "  -check:                check test suites (names of each test is unique)"
echo "  -track-stack:          track stack in malloc and turns on -warn option"
echo "  -noplay:               disables MP4Client tests"
echo "  -test=NAME             only executes given test"
echo "  -v:                    set verbose output"
echo "  -h:                    print this help"
}

#performs mirroring of media and references hash & videos
sync_media ()
{
 log $L_INF "- Mirroring $REFERENCE_DIR/media/ to $EXTERNAL_MEDIA_DIR"
 if [ ! -e $EXTERNAL_MEDIA_DIR ] ; then
  mkdir $EXTERNAL_MEDIA_DIR
 fi
 cd $EXTERNAL_MEDIA_DIR
 wget -q -m -nH --no-parent --cut-dirs=4 --reject "*.gif" "$REFERENCE_DIR/media/"
 cd "$main_dir"
}

#performs mirroring of media
sync_hash ()
{
log $L_INF "- Mirroring reference hashes from from $REFERENCE_DIR to $HASH_DIR"
cd $HASH_DIR
wget -q -m -nH --no-parent --cut-dirs=4 --reject "*.gif" "$REFERENCE_DIR/hash_refs/"
cd "$main_dir"
}

#performs mirroring of media and references hash & videos
sync_refs ()
{
log $L_INF "- Mirroring reference videos from $REFERENCE_DIR to $VIDEO_DIR_REF"
cd $VIDEO_DIR_REF
wget -q -m -nH --no-parent --cut-dirs=4 --reject "*.gif" "$REFERENCE_DIR/video_refs/"
cd "$main_dir"
}

url_arg=""
do_clean=0
keep_avi=0
do_clean_hash=0
check_only=0
disable_hash=0
strict_mode=0
track_stack=0
speed=1
single_test_name=""
erase_temp_dir=1

#Parse arguments
for i in $* ; do
 case $i in
 "-hash")
  generate_hash=1;;
 "-play-all")
   play_all=1;;
 "-clean")
   do_clean=1;;
 "-clean-hash")
   do_clean_hash=1;;
 "-uirec")
  global_test_ui=1;;
 "-uiplay")
  global_test_ui=2;;
 -speed*)
  speed="${i#-speed=}"
  ;;
 "-keep-avi")
  keep_avi=1;;
 "-keep-tmp")
  erase_temp_dir=0;;
 "-no-hash")
  disable_hash=1;;
 "-strict")
  strict_mode=1;;
 "-do-fuzz")
  enable_fuzzing=1;;
 -fuzzdur*)
  fuzz_duration="${i#-fuzzdur=}"
  ;;
 "-fuzzall")
  fuzz_all=1;;
 "-keepfuzz")
  no_fuzz_cleanup=1;;
 "-sync-hash")
  sync_hash
  exit;;
 "-sync-media")
  sync_media;;
 "-sync-refs")
  sync_refs
  exit;;
 "-sync-before")
  sync_media;;
 "-check")
  check_only=1;;
 "-warn")
  log_after_fail=1;;
 "-track-stack")
  track_stack=1;;
 "-noplay")
	MP4CLIENT_NOT_FOUND=1;;
 -test*)
  single_test_name="${i#-test=}"
  ;;
 "-v")
  verbose=1;;
 "-h")
  print_usage
  exit;;
 -*)
   log $L_ERR "Unknown Option \"$i\" - check usage (-h)"
   exit;;
 *)
  if [ -n "$url_arg" ] ; then
   log $L_ERR "More than one input specified - check usage (-h)"
   exit
  else
   url_arg=$i
  fi
 ;;
esac
done

if [ $check_only != 0 ] ; then
 do_clean_hash=0
 do_clean=0
 global_test_ui=0
fi

#Clean all hashes and reference videos
if [ $do_clean_hash != 0 ] ; then

 #force cleaning as well
 do_clean=1

 if [ -n "$url_arg" ] ; then
  do_clean=1
 else
  read -p "This will remove all referenced videos and hashes. Are you sure (y/n)?" choice
  if [ $choice != "y" ] ; then
   log $L_ERR "Canceled"
   exit
  fi
  log $L_INF "Deleting SHA-1 Hashes"
  rm -rf $HASH_DIR/* 2> /dev/null
  rm -rf $VIDEO_DIR_REF/* 2> /dev/null
 fi
fi

#Clean all cached results and generated videos
if [ $do_clean != 0 ] ; then
 rm -f $ALL_REPORTS > /dev/null
 rm -f $ALL_LOGS > /dev/null
 rm -rf $TEMP_DIR/* 2> /dev/null
 if [ -n "$url_arg" ] ; then
  do_clean=1
 else
  echo "Deleting cache (logs, stats and videos)"
  rm -rf $LOGS_DIR/* > /dev/null
  rm -rf $VIDEO_DIR/* 2> /dev/null
  exit
 fi
fi

log $L_INF "Checking test suite config"

if [ $generate_hash = 0 ] ; then
 if [ ! "$(ls -A $HASH_DIR)" ]; then
  disable_hash=1
  log $L_WAR "- Reference hashes unavailable - you may sync them using -sync-hash  - skipping hash tests"
  else
  log $L_INF "- Reference hashes available - enabling hash tests"
 fi
fi

if [ ! -e $EXTERNAL_MEDIA_DIR ] ; then
EXTERNAL_MEDIA_AVAILABLE=0
elif [ ! -e $EXTERNAL_MEDIA_DIR/counter ] ; then
EXTERNAL_MEDIA_AVAILABLE=0
fi

if [ $EXTERNAL_MEDIA_AVAILABLE = 0 ] ; then
 log $L_WAR "- External media dir unavailable - you may sync it using -sync-media"
else
 log $L_INF "- External media dir available"
fi

#test for GNU time
$GNU_TIME ls > /dev/null 2>&1
res=$?
if [ $res != 0 ] ; then
log $L_ERR "GNU time not found (ret $res) - exiting"
exit 1
fi

#test for GNU date
$GNU_DATE > /dev/null 2>&1
res=$?
if [ $res != 0 ] ; then
log $L_ERR "GNU date not found (ret $res) - exiting"
exit 1
fi

#test for timeout
$GNU_TIMEOUT 1.0 ls > /dev/null 2>&1
res=$?
if [ $res != 0 ] ; then
 log $L_ERR "GNU timeout not found (ret $res) - some tests may hang forever ..."
 enable_timeout=0
 if [ $enable_fuzzing != 0 ] ; then
  log $L_ERR "GNU timeout not found - disabling fuzzing"
  enable_fuzzing=0
 fi
else
enable_timeout=1
fi

#test for ffmpeg - if not present, disable video storing
do_store_video=1

if [ $check_only = 0 ] ; then

$FFMPEG -version > /dev/null 2>&1
if [ $? != 0 ] ; then
log $L_WAR "- FFMPEG not found - disabling playback video storage"
do_store_video=0
else
  if [ $generate_hash != 0 ] ; then
	log $L_INF "- Generating reference videos"
  fi
fi

#check MP4Box, MP4Client and MP42TS (use default args, not custum ones because of -mem-track)
MP4Box -h 2> /dev/null
res=$?
if [ $res != 0 ] ; then
log $L_ERR "MP4Box not found (ret $res) - exiting"
exit 1
fi

MP4CLIENT="MP4Client"

if [ $MP4CLIENT_NOT_FOUND = 0 ] && [ $do_clean = 0 ] ; then
  MP4Client -run-for 0 2> /dev/null
  res=$?
  if [ $res != 0 ] ; then
    MP4CLIENT_NOT_FOUND=1
    echo ""
    log $L_WAR "WARNING: MP4Client not found (ret $res) - launch results:"
    MP4Client -run-for 0
    res=$?
    if [ $res = 0 ] ; then
      log $L_INF "MP4Client returned $res on second run - enabling all playback tests"
    else
      echo "** MP4Client returned $res - disabling all playback tests - dumping GPAC config file **"
      cat $HOME/.gpac/GPAC.cfg
      echo "** End of dump **"
    fi
  fi
fi

MP42TS -h 2> /dev/null
res=$?
if [ $res != 0 ] ; then
log $L_ERR "MP42TS not found (ret $res) - exiting"
exit 1
fi

#check mem tracking is supported
res=`MP4Box -mem-track -h 2>&1 | grep "WARNING"`
if [ -n "$res" ]; then
  log $L_WAR "- GPAC not compiled with memory tracking"
else
 log $L_INF "- Enabling memory-tracking"
 if [ $track_stack = 1 ]; then
  base_args="$base_args -mem-track-stack"
  log_after_fail=1
 else
  base_args="$base_args -mem-track"
 fi
fi

#end check_only
fi

#check for afl-fuzz
if [ $enable_fuzzing != 0 ] ; then
 log $L_INF "Checking for afl-fuzz"
 command -v afl-fuzz >/dev/null 2>&1
 if [ $? != 0 ] ; then
  log $L_WAR "afl-fuzz not found - disabling fuzzing"
  enable_fuzzing=0
 else
  mkdir tmpafi
  mkdir tmpafo

  echo "void" > tmpafi/void.mp4
  $GNU_TIMEOUT 3.0 afl-fuzz -d -i tmpafi -o tmpafo MP4Box -h > /dev/null
  if [ $? != 0 ] ; then
   log $L_WAR "afl-fuzz not properly configure:"
   afl-fuzz -d -i tmpafi -o tmpafo MP4Box -h
   exit
  else
   log $L_INF "afl-fuzz found and OK - enabling fuzzing with duration $fuzz_duration"
  fi
  rm -rf tmpaf*
 fi
fi

echo ""

#reassign our default programs
MP4BOX="MP4Box -noprog -for-test $base_args"
MP4CLIENT="MP4Client -noprog -strict-error $base_args"
MP42TS="MP42TS $base_args"
DASHCAST="DashCast $base_args"

$MP4BOX -version 2> $TEMP_DIR/version.txt
VERSION="`head -1 $TEMP_DIR/version.txt | cut -d ' ' -f 5-` "
rm $TEMP_DIR/version.txt

#reset all the possible return values
reset_stat ()
{
 EXECUTION_STATUS="N/A"
 RETURN_VALUE="N/A"
 MEM_TOTAL_AVG="N/A"
 MEM_RESIDENT_AVG="N/A"
 MEM_RESIDENT_MAX="N/A"
 CPU_PERCENT="N/A"
 CPU_ELAPSED_TIME="N/A"
 CPU_USER_TIME="N/A"
 CPU_KERNEL_TIME="N/A"
 PAGE_FAULTS="N/A"
 FILE_INPUTS="N/A"
 SOCKET_MSG_REC="N/A"
 SOCKET_MSG_SENT="N/A"
}

#begin a test with name $1 and using hashes called $1-$2 ... $1-$N
test_begin ()
{
  if [ $# -gt 1 ] ; then
   log $L_ERR "> in script $current_script line $BASH_LINENO"
   log $L_ERR "	@test_begin takes only two arguments - wrong call (first arg is $1)"
  fi

 test_skip=0
 result=""
 TEST_NAME=$1
 fuzz_test=$fuzz_all
 reference_hash_valid="$HASH_DIR/$TEST_NAME-valid-hash"

 log $L_DEB "Starting test $TEST_NAME"

 if [ $do_clean != 0 ] ; then
  if [ $do_clean_hash != 0 ] ; then
   rm -rf $HASH_DIR/$TEST_NAME* 2> /dev/null
   rm -rf $VIDEO_DIR_REF/$TEST_NAME* 2> /dev/null
   rm -rf $reference_hash_valid 2> /dev/null
  fi
  rm -rf $LOGS_DIR/$TEST_NAME* > /dev/null
  rm -rf $VIDEO_DIR/$TEST_NAME* 2> /dev/null
  test_skip=1
  return
 fi

 if [ $check_only != 0 ] ; then
  test_ui=0
  report="$TEMP_DIR/$TEST_NAME.test"
  if [ -f $report ] ; then
   log $L_ERR "Test $TEST_NAME already exists - please fix ($current_script)"
   rm -rf $TEMP_DIR/* 2> /dev/null
   exit
  fi
  echo "" > $report
  test_skip=1
  return
 fi

 report="$TEMP_DIR/$TEST_NAME-temp.txt"
 LOGS="$LOGS_DIR/$TEST_NAME-logs.txt-new"
 final_report="$LOGS_DIR/$TEST_NAME-passed.xml"

 #reset defaults
 dump_dur=$DEF_DUMP_DUR
 dump_size=$DEF_DUMP_SIZE
 test_timeout=$DEF_TIMEOUT

 test_skip=0
 single_test=0

 test_args="$@"
 test_nb_args=$#
 skip_play_hash=0
 subtest_idx=0
 nb_subtests=0
 test_ui=$global_test_ui

 test_stats="$LOGS_DIR/$TEST_NAME-stats.sh"

 #if error in strict mode, mark the test as skippable using value 2
 if [ $strict_mode = 1 ] ; then
  if [ -f $TEST_ERR_FILE ] ; then
   test_skip=2
  fi
 fi

 if [ $MP4CLIENT_NOT_FOUND > 0 ] ; then
  skip_play_hash=1
 fi

 if [ $generate_hash = 1 ] ; then
  #skip test only if reference hash is marked as valid
  if [ -f "$reference_hash_valid" ] ; then
   log $L_DEB "Reference hash found for test $TEST_NAME - skipping hash generation"
   test_skip=1
  fi
 elif [ $test_ui != 0 ] ; then
   test_skip=0
 elif [ $test_skip = 0 ] ; then
  #skip test only if final report is present (whether we generate hashes or not)
  if [ -f "$final_report" ] ; then
   if [ -f "$test_stats" ] ; then
    log $L_DEB "$TEST_NAME already passed - skipping"
    test_skip=1
   else
    log $L_WAR "$TEST_NAME already passed but missing stats.sh - regenerating"
   fi
  fi
 fi

 if [ "$single_test_name" != "" ] && [ "$single_test_name" != "$TEST_NAME" ] ; then
   test_ui=0
   test_skip=1
 fi

 if [ $test_skip != 0 ] ; then
   #stats.sh may be missing when generating hashes and that's not an error
   if [ -f "$test_stats" ] ; then
    has_skip=`grep -w "TEST_SKIP" $test_stats`

    if [ "$has_skip" = "" ]; then
		echo "TEST_SKIP=$test_skip" >> $test_stats
    fi
   fi
   test_skip=1
 elif [ $test_ui != 0 ] ; then
   #in UI test mode don't check cache status, always run the tests
   test_skip=1
 else
  echo "*** $TEST_NAME logs (GPAC version $VERSION) - test date $(date '+%d/%m/%Y %H:%M:%S') ***" > $LOGS
  echo "" >> $LOGS
 fi

 rules_sh=$RULES_DIR/$TEST_NAME.sh
 if [ -f $rules_sh ] ; then
  source $rules_sh
 fi

}

mark_test_error ()
{
 if [ $strict_mode = 1 ] ; then
  echo "" > $TEST_ERR_FILE
  log $L_ERR "Error test $TEST_NAME subtest $SUBTEST_NAME - aborting"
 fi
}

#ends test - gather all logs/stats produced and generate report
test_end ()
{
 #wait for all sub-tests to complete (some may use subshells)
 wait

  if [ $# -gt 0 ] ; then
   log $L_ERR "> in test $TEST_NAME in script $current_script line $BASH_LINENO"
   log $L_ERR "	@test_end takes no argument - wrong call"
  fi

 if [ $test_skip = 1 ] ; then
  return
 fi

 test_stats="$LOGS_DIR/$TEST_NAME-stats.sh"
 echo "" > $test_stats
 stat_xml_temp="$TEMP_DIR/$TEST_NAME-statstemp.xml"
 echo "" > $stat_xml_temp

 test_fail=0
 test_leak=0
 test_exec_na=0
 nb_subtests=0
 nb_test_hash=0
 nb_hash_fail=0
 nb_hash_missing=0

 if [ "$result" != "" ] ; then
  test_fail=1
 fi

# makes glob on non existing files to expand to null
# enabling loops on nonexisting* to be empty
shopt -s nullglob

 #gather all stats per subtests
 for i in $TEMP_DIR/$TEST_NAME-stats-*.sh ; do
  reset_stat
  RETURN_VALUE=0
  SUBTEST_NAME=""
  COMMAND_LINE=""
  SUBTEST_IDX=0

  nb_subtests=$((nb_subtests + 1))

  source $i

  echo "  <stat subtest=\"$SUBTEST_NAME\" execution_status=\"$EXECUTION_STATUS\" return_status=\"$RETURN_STATUS\" mem_total_avg=\"$MEM_TOTAL_AVG\" mem_resident_avg=\"$MEM_RESIDENT_AVG\" mem_resident_max=\"$MEM_RESIDENT_MAX\" cpu_percent=\"$CPU_PERCENT\" cpu_elapsed_time=\"$CPU_ELAPSED_TIME\" cpu_user_time=\"$CPU_USER_TIME\" cpu_kernel_time=\"$CPU_KERNEL_TIME\" page_faults=\"$PAGE_FAULTS\" file_inputs=\"$FILE_INPUTS\" socket_msg_rec=\"$SOCKET_MSG_REC\" socket_msg_sent=\"$SOCKET_MSG_SENT\" return_value=\"$RETURN_VALUE\">" >> $stat_xml_temp

  echo "   <command_line>$COMMAND_LINE</command_line>" >> $stat_xml_temp
  echo "  </stat>" >> $stat_xml_temp

  test_ok=1

  if [ $RETURN_VALUE -eq 1 ] ; then
   result="$SUBTEST_NAME:Fail $result"
   test_ok=0
   test_fail=$((test_fail + 1))
  elif [ $RETURN_VALUE -eq 2 ] ; then
   result="$SUBTEST_NAME:MemLeak $result"
   test_ok=0
   test_leak=$((test_leak + 1))
  elif [ $RETURN_VALUE != 0 ] ; then
   if [ $enable_timeout != 0 ] && [ $RETURN_VALUE = 124 ] ; then
    result="$SUBTEST_NAME:Timeout $result"
   else
    result="$SUBTEST_NAME:Fail(ret code $RETURN_VALUE) $result"
   fi
   test_ok=0
   test_fail=$((test_fail + 1))
  fi

  if [ $log_after_fail = 1 ] ; then
   if [ $test_ok = 0 ] ; then
    sublog=$LOGS_DIR/$TEST_NAME-logs-$SUBTEST_IDX-$SUBTEST_NAME.txt
    if [ -f $sublog ] ; then
	 cat $sublog 2> stderr
    fi
   fi
  fi
  rm -f $i > /dev/null
 done

 #gather all hashes for this test
 for i in $TEMP_DIR/$TEST_NAME-stathash-*.sh ; do
  if [ -f $i ] ; then
   HASH_TEST=""
   HASH_NOT_FOUND=0
   HASH_FAIL=0

   source $i
   nb_test_hash=$((nb_test_hash + 1))
   if [ $HASH_NOT_FOUND -eq 1 ] ; then
    result="$HASH_TEST:HashNotFound $result"
    nb_hash_missing=$((nb_hash_missing + 1))
    test_exec_na=$((test_exec_na + 1))
   elif [ $HASH_FAIL -eq 1 ] ; then
    result="$HASH_TEST:HashFail $result"
    test_ok=0
    nb_hash_fail=$((nb_hash_fail + 1))
    test_exec_na=$((test_exec_na + 1))
   fi
  fi
  rm -f $i > /dev/null
 done

 if [ "$result" = "" ] ; then
  result="OK"
 fi

 if [ ! -f $TEST_ERR_FILE ] ; then
  if [ $generate_hash = 1 ] ; then
    log $L_DEB "Test $TEST_NAME $nb_subtests subtests and $nb_test_hash hashes"
    nb_hashes=$((nb_test_hash + nb_test_hash))
	#only allow no hash if only one subtest
    if [ $subtest_idx -gt 1 ] && [ $nb_hashes -lt $subtest_idx ] ; then
     log $L_ERR "Test $TEST_NAME has too few hash tests: $nb_hashes for $nb_subtests subtests - please fix"
     result="NOT ENOUGH HASHES"
    else
		echo "ok" > $reference_hash_valid
	fi
#    if [ $nb_test_hash -gt 15 ] ; then
#     log $L_WAR "Test $TEST_NAME has too many subtests with hashes ($nb_test_hash), not efficient for hash generation - consider rewriting $current_script"
#	fi
  fi
 fi

 echo " <test name=\"$TEST_NAME\" result=\"$result\" date=\"$(date '+%d/%m/%Y %H:%M:%S')\">" > $report
 cat $stat_xml_temp >> $report
 rm -f $stat_xml_temp > /dev/null
 echo " </test>" >> $report

 echo "TEST_FAIL=$test_fail" >> $test_stats
 echo "TEST_EXEC_NA=$test_exec_na" >> $test_stats
 echo "SUBTESTS_LEAK=$test_leak" >> $test_stats
 echo "NB_HASH_SUBTESTS=$nb_test_hash" >> $test_stats
 echo "NB_HASH_SUBTESTS_MISSING=$nb_hash_missing" >> $test_stats
 echo "NB_HASH_SUBTESTS_FAIL=$nb_hash_fail" >> $test_stats

 # list all logs files
 for i in $LOGS_DIR/$TEST_NAME-logs-*.txt; do
  cat $i >> $LOGS
 done
 rm -f $LOGS_DIR/$TEST_NAME-logs-*.txt > /dev/null

 echo "NB_SUBTESTS=$nb_subtests" >> $test_stats

 if [ "$result" == "OK" ] ; then
  mv $report "$LOGS_DIR/$TEST_NAME-passed-new.xml"

  echo "$TEST_NAME: $result"
 else
  mv $report "$LOGS_DIR/$TEST_NAME-failed.xml"
  mark_test_error

  log $L_ERR "$TEST_NAME: $result"
 fi

}

do_fuzz()
{
  cmd="$2"
  fuzz="@@"
  fuzz_cmd=${cmd/$1/$fuzz}
  file_ext="${1##*.}"
  orig_path=`pwd`
  tests_gen=0
  log $L_DEB "Fuzzing file $1 with command line $fuzz_cmd"

  fuzz_res_dir="$LOCAL_OUT_DIR/fuzzing/$TEST_NAME_$SUBTEST_NAME/$fuzz_sub_idx"
  fuzz_temp_dir="$LOCAL_OUT_DIR/fuzzing/$TEST_NAME_$SUBTEST_NAME/$fuzz_sub_idx/temp"
  mkdir -p "$fuzz_res_dir"
  mkdir -p "$fuzz_temp_dir/in/"
  mkdir -p "$fuzz_temp_dir/out/"

  cp $1 "$fuzz_temp_dir/in/"
  cd $fuzz_temp_dir

  $GNU_TIMEOUT $fuzz_duration afl-fuzz -d -i "in/" -o "out/" $fuzz_cmd
  if [ $? = 0 ] ; then
   if [ $no_fuzz_cleanup = 0 ] ; then
    #rename all crashes and hangs
    cd out/crashes
    ls | cat -n | while read n f; do mv "$f" "$fuzz_res_dir/crash_$n.$file_ext"; done
    cd ../hangs
    ls | cat -n | while read n f; do mv "$f" "$fuzz_res_dir/hang_$n.$file_ext"; done
    cd ../..
    rm -f "$fuzz_res_dir/readme.txt"
   fi
  fi

  cd "$orig_path"

  if [ $no_fuzz_cleanup = 0 ] ; then
   rm -rf $fuzz_temp_dir

   tests_gen=`ls $fuzz_res_dir | wc -w`
   if [ $no_fuzz_cleanup != 0 ] ; then
    tests_gen=1
   fi

   if [ $tests_gen = 0 ] ; then
    rm -rf $fuzz_res_dir
   else
    echo "Generated with afl-fuzz -d $fuzz_cmd" > "$fuzz_res_dir/readme.txt"
   fi
  fi
}

#@do_test execute the command line given $1 using GNU time and store stats with return value, command line ($1) and subtest name ($2)
ret=0
do_test ()
{

  if [ $# -gt 2 ] ; then
   log $L_ERR "> in test $TEST_NAME in script $current_script line $BASH_LINENO"
   log $L_ERR "	@do_test takes only two arguments - wrong call (first arg $1)"
  fi

 if [ $strict_mode = 1 ] ; then
  if [ -f $TEST_ERR_FILE ] ; then
   return
  fi
 fi

 if [ $test_skip = 1 ] ; then
  return
 fi

 if [ $MP4CLIENT_NOT_FOUND != 0 ] ; then
	case $1 in MP4Client*)
		return
	esac
 fi
 log L_DEB "executing $1"

 subtest_idx=$((subtest_idx + 1))

 log_subtest="$LOGS_DIR/$TEST_NAME-logs-$subtest_idx-$2.txt"
 stat_subtest="$TEMP_DIR/$TEST_NAME-stats-$subtest_idx-$2.sh"
 SUBTEST_NAME=$2

 if [ $enable_fuzzing = 0 ] ; then
  fuzz_test=0
 fi

 #fuzzing on: check all args, detect ones matching input files in $maindir and fuzz them
 #note that this is not perfect since the command line may modify an existing MP4
 #so each successfull afl-fuzz test (not call!) will modify the input...
 if [ $fuzz_test != 0 ] ; then
  fuzz_dir="$LOCAL_OUT_DIR/fuzzing/$TEST_NAME_$SUBTEST_NAME/"
  mkdir -p fuzz_dir
  fuzz_sub_idx=1
  for word in $1 ; do
   is_file_arg=0
   case "$word" in
     $main_dir/*)
      is_file_arg=1;;
   esac

   if [ $is_file_arg != 0 ] ; then
    fuzz_src=${word%:*}
    if [ -f $fuzz_src ] ; then
      do_fuzz "$fuzz_src" "$1"
      fuzz_sub_idx=$((fuzz_sub_idx + 1))
    fi
   fi
  done

  if [ $no_fuzz_cleanup = 0 ] ; then
   crashes=`ls $fuzz_dir | wc -w`
   if [ $crashes = 0 ] ; then
    rm -rf $fuzz_dir
   fi
  fi

  #we still run the subtest in fuzz mode, since further subtests may use the output of this test
 fi

echo "" > $log_subtest
echo "*** Subtest \"$2\": executing \"$1\" ***" >> $log_subtest

timeout_args=""
if [ $enable_timeout != 0 ] ; then
timeout_args="$GNU_TIMEOUT $test_timeout"
fi

$timeout_args $GNU_TIME -o $stat_subtest -f ' EXECUTION_STATUS="OK"\n RETURN_STATUS=%x\n MEM_TOTAL_AVG=%K\n MEM_RESIDENT_AVG=%t\n MEM_RESIDENT_MAX=%M\n CPU_PERCENT=%P\n CPU_ELAPSED_TIME=%E\n CPU_USER_TIME=%U\n CPU_KERNEL_TIME=%S\n PAGE_FAULTS=%F\n FILE_INPUTS=%I\n SOCKET_MSG_REC=%r\n SOCKET_MSG_SENT=%s' $1 >> $log_subtest 2>&1
rv=$?

echo "SUBTEST_NAME=$2" >> $stat_subtest
echo "SUBTEST_IDX=$subtest_idx" >> $stat_subtest

#regular error, check if this is a negative test.
if [ $rv -eq 1 ] ; then
 if [ $single_test = 1 ] ; then
  negative_test_stderr=$RULES_DIR/$TEST_NAME-stderr.txt
 else
  negative_test_stderr=$RULES_DIR/$TEST_NAME-$2-stderr.txt
 fi
 if [ -f $negative_test_stderr ] ; then
  #look for all lines in -stderr file, if one found consider this a success
  while read line ; do
   res_err=`grep -o "$line" $log_subtest`
   if [ -n "$res_err" ]; then
    echo "Negative test detected, reverting to success (found \"$res_err\" in stderr)" >> $log_subtest
    rv=0
    echo "" > $stat_subtest
    break
   fi
  #remove windows style endlines as they may cause some problems
  #also remove empty lines otherwise grep always matches
  done < <(tr -d '\r' <$negative_test_stderr | sed '/^$/d' )
 fi
fi

#override generated stats if error, since gtime may put undesired lines in output file which would break sourcing
if [ $rv != 0 ] ; then
echo "SUBTEST_NAME=$2" > $stat_subtest
echo "SUBTEST_IDX=$subtest_idx" >> $stat_subtest
mark_test_error
fi

echo "RETURN_VALUE=$rv" >> $stat_subtest
echo "COMMAND_LINE=\"$1\"" >> $stat_subtest

echo "" >> $log_subtest
ret=$rv
}
#end do_test

#@do_playback_test: checks for user input record if any, then launch MP4Client with $1 with dump_dur and dump_size video sec AVI recording, then checks audio and video hash of the dump and convert the video to MP4 when generating the hash. The results are logged as with do_test

do_playback_test ()
{

  if [ $# -gt 2 ] ; then
   log $L_ERR "> in test $TEST_NAME in script $current_script line $BASH_LINENO"
   log $L_ERR "	@do_playback_test takes only two arguments - wrong call (first arg is $1)"
  fi

 if [ $strict_mode = 1 ] ; then
  if [ -f $TEST_ERR_FILE ] ; then
   return
  fi
 fi

 if [ $test_skip  = 1 ] ; then
  return
 fi

 if [ $single_test = 1 ] ; then
  FULL_SUBTEST="$TEST_NAME"
 else
  FULL_SUBTEST="$TEST_NAME-$2"
 fi
 AVI_DUMP="$TEMP_DIR/$FULL_SUBTEST-dump"

 args="$MP4CLIENT -avi 0-$dump_dur -out $AVI_DUMP -size $dump_size $1"

 ui_rec=$RULES_DIR/$FULL_SUBTEST-ui.xml

 if [ -f $ui_rec ] ; then
  args="$args -opt Validator:Mode=Play -opt Validator:Trace=$ui_rec"
 else
  args="$args -opt Validator:Mode=Disable"
 fi
 do_test "$args" $2

 #don't try hash if error
 if [ $ret != 0 ] ; then
  return
 fi

 if [ $skip_play_hash = 0 ] ; then
  #since AVI dump in MP4Client is based on real-time grab of multithreaded audio and video render
  #we may have interleaving differences in the resulting AVI :(
  #we generate a hash for both audio and video since we don't have a fix yet
  #furthermore this will allow figuring out if the error is in the video or the audio renderer
  $MP4BOX -aviraw video "$AVI_DUMP.avi" -out "$AVI_DUMP.video" > /dev/null 2>&1
  do_hash_test "$AVI_DUMP.video" "$2-avirawvideo"
  rm "$AVI_DUMP.video" 2> /dev/null

  $MP4BOX -aviraw audio "$AVI_DUMP.avi" -out "$AVI_DUMP.audio" > /dev/null 2>&1
  do_hash_test "$AVI_DUMP.audio" "$2-avirawaudio"
  rm "$AVI_DUMP.audio" 2> /dev/null
 fi

 if [ $do_store_video != 0 ] ; then
  if [ $generate_hash != 0 ] ; then
   ffmpeg_encode "$AVI_DUMP.avi" "$VIDEO_DIR_REF/$FULL_SUBTEST-ref.mp4"
  else
   ffmpeg_encode "$AVI_DUMP.avi" "$VIDEO_DIR/$FULL_SUBTEST-test.mp4"
  fi
 fi

if [ $keep_avi != 0 ] ; then
 if [ $generate_hash != 0 ] ; then
   mv "$AVI_DUMP.avi" "$VIDEO_DIR_REF/$FULL_SUBTEST-raw-ref.avi"
  else
   mv "$AVI_DUMP.avi" "$VIDEO_DIR/$FULL_SUBTEST-raw-test.avi"
  fi
else
  rm "$AVI_DUMP.avi" 2> /dev/null
fi

}
#end do_playback_test

#@do_hash_test: generates a hash for $1 file , compare it to HASH_DIR/$TEST_NAME$2.hash
do_hash_test ()
{

  if [ $# -gt 2 ] ; then
   log $L_ERR "> in test $TEST_NAME in script $current_script line $BASH_LINENO"
   log $L_ERR "	@do_hash_test takes only two argument - wrong call (first arg is $1)"
  fi
 if [ $strict_mode = 1 ] ; then
  if [ -f $TEST_ERR_FILE ] ; then
   return
  fi
 fi

 if [ $test_skip  = 1 ] ; then
  return
 fi
 log L_DEB "Generating hash for $1"

 if [ $disable_hash = 1 ] ; then
  return
 fi

 STATHASH_SH="$TEMP_DIR/$TEST_NAME-stathash-$2.sh"

 test_hash="$TEMP_DIR/$TEST_NAME-$2-test.hash"
 ref_hash="$HASH_DIR/$TEST_NAME-$2.hash"

 echo "HASH_TEST=$2" > $STATHASH_SH

 echo "Computing $1  ($2) hash: " >> $log_subtest
 file_to_hash="$1"

 # for text files, we remove potential CR chars
 # to prevent having different hashes on different platforms
 if [ -n "$(file -b $1 | grep text)" ] ||  [ ${1: -4} == ".lsr" ] ; then
  file_to_hash="to_hash_$(basename $1)"
  tr -d '\r' <  "$1" > "$file_to_hash"
 fi

 $MP4BOX -hash -std $file_to_hash > $test_hash 2>> $log_subtest

 if [ "$file_to_hash" != "$1" ]; then
  rm "$file_to_hash"
 fi

 if [ $generate_hash = 0 ] ; then
  if [ ! -f $ref_hash ] ; then
   echo "HASH_NOT_FOUND=1" >> $STATHASH_SH
   return
  fi

  echo "HASH_NOT_FOUND=0" >> $STATHASH_SH

  $DIFF $test_hash $ref_hash > /dev/null
  rv=$?

  if [ $rv != 0 ] ; then
   fhash=`hexdump -ve '1/1 "%.2X"' $ref_hash`
   echo "Hash fail, ref hash $ref_hash was $fhash"  >> $log_subtest
   echo "HASH_FAIL=1" >> $STATHASH_SH
  else
   echo "Hash OK for $1"  >> $log_subtest
   echo "HASH_FAIL=0" >> $STATHASH_SH
  fi
  rm $test_hash

 else
  mv $test_hash $ref_hash
 fi
}
#end do_hash_test

#compare hashes of $1 and $2, return 0 if OK, error otherwise
do_compare_file_hashes ()
{
  if [ $# -gt 2 ] ; then
   log $L_ERR "> in test $TEST_NAME in script $current_script line $BASH_LINENO"
   log $L_ERR "	@do_compare_file_hashes takes only two arguments - wrong call (first arg is $1)"
  fi
test_hash_first="$TEMP_DIR/$TEST_NAME-$(basename $1).hash"
test_hash_second="$TEMP_DIR/$TEST_NAME-$(basename $2).hash"

$MP4BOX -hash -std $1 > $test_hash_first 2> /dev/null
$MP4BOX -hash -std $1 > $test_hash_second 2> /dev/null
$DIFF $test_hash_first $test_hash_first > /dev/null

rv=$?
if [ $rv != 0 ] ; then
echo "Hash fail between $1 and $2"  >> $log_subtest
else
echo "Same Hash for $1 and $2"  >> $log_subtest
fi

rm $test_hash_first
rm $test_hash_second

return $rv

}
#end do_compare_file_hashes

#@ffmpeg_encode: encode source file $1 to $2 using default ffmpeg settings
ffmpeg_encode ()
{
  if [ $# -gt 2 ] ; then
   log $L_ERR "> in test $TEST_NAME in script $current_script line $BASH_LINENO"
   log $L_ERR "	@ffmpeg_encode takes only two arguments - wrong call (first arg is $1)"
  fi
 #run ffmpeg in force overwrite mode
 $FFMPEG -y -i $1 -pix_fmt yuv420p -strict -2 $2 2> /dev/null
}
#end

#@single_test: performs a single test without hash with $1 command line and $2 test name
single_test ()
{
  if [ $# -gt 2 ] ; then
   log $L_ERR "> in test $TEST_NAME in script $current_script line $BASH_LINENO"
   log $L_ERR "	@single_test takes only two arguments - wrong call (first arg is $1)"
  fi
test_begin "$2"
if [ $test_skip  = 1 ] ; then
return
fi
single_test=1
do_test $1 "single"
test_end
}

#@single_playback_test: performs a single playback test with hashes with $1 command line and $2 test name
single_playback_test ()
{
  if [ $# -gt 2 ] ; then
   log $L_ERR "> in test $TEST_NAME in script $current_script line $BASH_LINENO"
   log $L_ERR "	@single_playback_test takes only two arguments - wrong call (first arg is $1)"
  fi
test_begin "$2"
if [ $test_skip  = 1 ] ; then
return
fi
single_test=1
do_playback_test "$1" "play"
test_end
}

#@test_ui_test: if $test_ui is 1 records user input on $1 playback (10 sec) and stores in $RULES_DIR/$1-ui.xml. If $test_ui is 2, plays back the recorded stream
do_ui_test()
{
  if [ $# -gt 2 ] ; then
   log $L_ERR "> in test $TEST_NAME in script $current_script line $BASH_LINENO"
   log $L_ERR "	@test_ui_test takes one or two arguments - wrong call (first arg is $1)"
  fi

 if [ $test_ui = 0 ] ; then
  return
 fi

 if [ "$single_test_name" != "" ] && [ "$single_test_name" != "$TEST_NAME" ] ; then
   log $L_DEB "skiping ui test $TEST_NAME"
   return
 fi

 src=$1
 if [ $# -gt 1 ] ; then
  FULL_SUBTEST="$TEST_NAME-$2"
 else
  FULL_SUBTEST="$TEST_NAME"
 fi

 SUBTEST=$2
 ui_stream=$RULES_DIR/$FULL_SUBTEST-ui.xml

 if [ $test_ui = 1 ] ; then
  if [ -f $ui_stream ]; then
   log $L_DEB "User input trace present for $FULL_SUBTEST - skipping"
   return
  fi
  echo "Recording user input for $FULL_SUBTEST"
  echo "Recording user input for $FULL_SUBTEST (file $src) into trace $ui_stream" >> $ALL_LOGS
  $MP4CLIENT -run-for $dump_dur -size $dump_size $src -no-save -opt Validator:Mode=Record -opt Validator:Trace=$ui_stream 2>> $ALL_LOGS
  rv=$?
 else
  if [ ! -f $ui_stream ]; then
   log $L_WAR "User input trace not found for $FULL_SUBTEST - skipping playback"
   return
  fi
  echo "Playing user input for $FULL_SUBTEST"
  echo "Playing user input for $FULL_SUBTEST (file $src) from trace $ui_stream" >> $ALL_LOGS
  dur=$(($dump_dur / $speed))
  $MP4CLIENT -run-for $dur -size $dump_size $src -speed $speed -no-save -opt Validator:Mode=Play -opt Validator:Trace=$ui_stream 2>> $ALL_LOGS
  rv=$?
 fi
 #regular error, check if this is a negative test.
 if [ $rv != 0 ] ; then
  log $L_ERR "Error executing UI test for $FULL_SUBTEST (source file $src - test name $TEST_NAME)"
#  if [ $strict_mode = 1 ] ; then
#   exit
#  fi
 fi
}
#end test_ui_test

#start of our tests
start=`$GNU_DATE +%s%N`
start_date="$(date '+%d/%m/%Y %H:%M:%S')"

if [ $generate_hash = 1 ] ; then
 log $L_INF "Generating Test Suite SHA-1 Hashes"
elif [ $do_clean = 1 ] ; then
 log $L_INF "Cleaning Test Suite"
elif [ $check_only = 1 ] ; then
 log $L_INF "Checking Test Suite Names"
elif [ $global_test_ui = 1 ] ; then
 log $L_INF "Generating User Input traces"
elif [ $global_test_ui = 2 ] ; then
 log $L_INF "Playing User Input traces"
else
 log $L_INF "Evaluating Test Suite"
fi

print_end()
{
end=`$GNU_DATE +%s%N`
runtime=$((end-start))

ms=$(($runtime / 1000000))
secs=$(($ms / 1000))
ms=$(($ms - $secs*1000))
h=$(($secs / 3600))
secs=$(($secs - $h*3600))
m=$(($secs / 60))
secs=$(($secs - $m*60))

printf "$1 in %02d:%02d:%02d:%03d\n" $h $m $secs $ms
}

#gather all tests reports and build our final report
finalize_make_test()
{

#we are cleaning, nothing to do
if [ $do_clean != 0 ] ; then
 print_end "Cleanup done"
 return
fi

#ui tests nothing to do
if [ $global_test_ui != 0 ] ; then
 print_end "UI Tests done"
 return
fi

#create logs and final report
echo "Logs for GPAC test suite - execution date $start_date" > $ALL_LOGS

echo '<?xml version="1.0" encoding="UTF-8"?>' > $ALL_REPORTS
echo '<?xml-stylesheet href="stylesheet.xsl" type="text/xsl"?>' >> $ALL_REPORTS
echo "<GPACTestSuite version=\"$VERSION\" platform=\"$platform\" start_date=\"$start_date\" end_date=\"$(date '+%d/%m/%Y %H:%M:%S')\">" >> $ALL_REPORTS

if [ $erase_temp_dir != 0 ] ; then
   rm -rf $TEMP_DIR/* 2> /dev/null
fi

#count all tests using generated -stats.sh
TESTS_SKIP=0
TESTS_TOTAL=0
TESTS_DONE=0
TESTS_PASSED=0
TESTS_FAILED=0
TESTS_LEAK=0
TESTS_EXEC_NA=0

SUBTESTS_FAIL=0
SUBTESTS_EXEC_NA=0
SUBTESTS_DONE=0
SUBTESTS_LEAK=0
SUBTESTS_HASH=0
SUBTESTS_HASH_FAIL=0
SUBTESTS_HASH_MISSING=0

for i in $LOGS_DIR/*-stats.sh ; do
if [ -f $i ] ; then

#reset stats
TEST_SKIP=0
TEST_EXEC_NA=0
SUBTESTS_LEAK=0
NB_HASH_SUBTESTS=0
NB_HASH_SUBTESTS_MISSING=0
NB_HASH_SUBTESTS_FAIL=0
NB_SUBTESTS=0

#load stats
source $i

#test not run due to error in strict mode
if [ $TEST_SKIP = 2 ] ; then
rm -f $i > /dev/null
continue;
fi

TESTS_TOTAL=$((TESTS_TOTAL + 1))
if [ $TEST_SKIP = 0 ] ; then
 TESTS_DONE=$((TESTS_DONE + 1))
cp $i "test.txt"
else
 TESTS_SKIP=$((TESTS_SKIP + $TEST_SKIP))
fi

if [ $TEST_FAIL = 0 ] ; then
  if [ $TEST_EXEC_NA = 0 ] && [ $SUBTESTS_LEAK = 0 ]; then
    TESTS_PASSED=$((TESTS_PASSED + 1))
  else
    rm -f $i > /dev/null
    if [ $TEST_EXEC_NA != 0 ] ; then
      TESTS_EXEC_NA=$((TESTS_EXEC_NA + 1))
    else
      TESTS_LEAK=$((TESTS_LEAK + 1))
    fi
  fi
else
  TESTS_FAILED=$((TESTS_FAILED + 1))
  rm -f $i > /dev/null
fi

SUBTESTS_FAIL=$((SUBTESTS_FAIL + $TEST_FAIL))
SUBTESTS_EXEC_NA=$((SUBTESTS_EXEC_NA + $TEST_EXEC_NA))
SUBTESTS_DONE=$((SUBTESTS_DONE + $NB_SUBTESTS))
SUBTESTS_LEAK=$((SUBTESTS_LEAK + $SUBTESTS_LEAK))
SUBTESTS_HASH=$((SUBTESTS_HASH + $NB_HASH_SUBTESTS))
SUBTESTS_HASH_FAIL=$((SUBTESTS_HASH_FAIL + $NB_HASH_SUBTESTS_FAIL))
SUBTESTS_HASH_MISSING=$((SUBTESTS_HASH_MISSING + $NB_HASH_SUBTESTS_MISSING))

fi

done

echo "<TestSuiteResults NumTests=\"$TESTS_TOTAL\" NumSubtests=\"$SUBTESTS_DONE\" TestsPassed=\"$TESTS_PASSED\" TestsFailed=\"$TESTS_FAILED\" TestsLeaked=\"$TESTS_LEAK\" TestsUnknown=\"$TESTS_EXEC_NA\" HashFailed=\"$SUBTESTS_HASH_FAIL\" HashMissing=\"$SUBTESTS_HASH_MISSING\" />" >> $ALL_REPORTS

#gather all failed reports first
for i in $LOGS_DIR/*-failed.xml; do
 if [ -f $i ] ; then
  cat $i >> $ALL_REPORTS
  echo "" >> $ALL_REPORTS
  rm $i
 fi
done

#gather all new reports
for i in $LOGS_DIR/*-passed-new.xml; do
 if [ -f $i ] ; then
  cat $i >> $ALL_REPORTS
  echo "" >> $ALL_REPORTS
  #move new report to final name
  n=${i%"-new.xml"}
  n="$n.xml"
  mv "$i" "$n"
 fi
done

echo '</GPACTestSuite>' >> $ALL_REPORTS

#cat all logs
for i in $LOGS_DIR/*-logs.txt-new; do
 if [ -f $i ] ; then
  cat $i >> $ALL_LOGS
  echo "" >> $ALL_LOGS
  #move new report to final name
  n=${i%".txt-new"}
  n="$n.txt"
  mv "$i" "$n"
 fi
done

if [ $TESTS_TOTAL = 0 ] ; then
log $L_INF "No tests executed"
else

pc1=$((100*TESTS_DONE/TESTS_TOTAL))
pc2=$((100*TESTS_SKIP/TESTS_TOTAL))
log $L_INF "Number of Tests $TESTS_TOTAL - $SUBTESTS_DONE subtests - Executed: $TESTS_DONE ($pc1 %) - Cached: $TESTS_SKIP ($pc2 %)"

if [ $TESTS_DONE = 0 ] ; then
 TESTS_DONE=$TESTS_TOTAL
fi
if [ $SUBTESTS_DONE = 0 ] ; then
 SUBTESTS_DONE=$TESTS_TOTAL
fi

 pc=$((100*TESTS_PASSED/TESTS_TOTAL))
 log $L_INF "Tests passed $TESTS_PASSED ($pc %) - $SUBTESTS_DONE sub-tests"

 # the follwing % are in subtests
 if [ $SUBTESTS_FAIL != 0 ] ; then
  pc=$((100*SUBTESTS_FAIL/SUBTESTS_DONE))
  log $L_ERR "Tests failed $TESTS_FAILED ($pc % of subtests)"
 fi

 if [ $SUBTESTS_LEAK != 0 ] ; then
  pc=$((100*SUBTESTS_LEAK/SUBTESTS_DONE))
  log $L_WAR "Tests Leaked $TESTS_LEAK ($pc % of subtests)"
 fi

 if [ $SUBTESTS_EXEC_NA != 0 ] ; then
  pc=$((100*SUBTESTS_EXEC_NA/SUBTESTS_DONE))
  log $L_WAR "Tests Unknown $TESTS_EXEC_NA ($pc % of subtests)"
 fi

 if [ $SUBTESTS_HASH_FAIL != 0 ] ; then
  pc=$((100*SUBTESTS_HASH_FAIL/SUBTESTS_DONE))
  log $L_WAR "Tests HASH total $SUBTESTS_HASH - fail $SUBTESTS_HASH_FAIL ($pc % of subtests)"
 fi

 if [ $SUBTESTS_HASH_MISSING != 0 ] ; then
  pc=$((100*SUBTESTS_HASH_MISSING/$SUBTESTS_HASH))
  log $L_WAR "Missing hashes $SUBTESTS_HASH_MISSING / $SUBTESTS_HASH ($pc % hashed subtests)"
 fi

fi

print_end "Generation done"

} #end finalize_make_test

# trap ctrl-c and generate reports
trap ctrl_c_trap INT

ctrl_c_trap() {
	echo "CTRL-C trapped - cleanup and building up reports"
	local pids=$(jobs -pr)
	[ -n "$pids" ] && kill $pids
	finalize_make_test
	exit
}

# disable nullglobing in case sub-scripts aren't made for it
shopt -u nullglob

#run our tests
if [ -n "$url_arg" ] ; then
 current_script=$url_arg
 source $url_arg
else
 for i in $SCRIPTS_DIR/*.sh ; do
  if [ $verbose = 1 ] ; then
   log $L_DEB "Source script: $i"
  fi
  current_script=$i
  source $i
  cd $main_dir
  #break if error and error
  if [ $strict_mode = 1 ] ; then
   #wait for all tests to be done before checking error marker
   wait
   if [ -f $TEST_ERR_FILE ] ; then
    break
   fi
  fi
 done
fi

#wait for all tests to be done, since some tests may use subshells
wait

if [ $check_only != 0 ] ; then
 rm -rf $TEMP_DIR/* 2> /dev/null
 exit
fi

finalize_make_test


<filename>_make_thumbnails.sh
mogrify -path images -thumbnail 160x160 images/*.png
mogrify -path images -thumbnail 160x160 images/*.jpg


<gh_stars>10-100
{% extends '//bin/dash/mix.sh' %}

{% block bld_libs %}
lib/c
{% endblock %}

{% block std_box %}
bld/bootbox
{% endblock %}

{% block install %}
{{super()}}
cd ${out}/bin; mv dash sh
{% endblock %}

{% block configure1 %}
sh ./configure \
    --prefix="${out}"  \
    --disable-lineedit \
    --enable-printf    \
    --enable-test
{% endblock %}


<filename>pica/02-jvm-performance/demo/string-interning/start.sh
#!/bin/bash

ARG="$1"
if [[ -z "$ARG" ]]; then
    echo "Invalid argument"
else
    # Clean and build the project
    ./gradlew clean build

    # Run one of the scenarios
    case $ARG in
        # Invalid
        "0")
            java -XX:StringTableSize=0 -XX:+PrintStringTableStatistics -jar build/libs/string-interning.jar $2
            ;;
        # Really Bad one
        "1")
            java -XX:StringTableSize=1009 -XX:+PrintStringTableStatistics -jar build/libs/string-interning.jar $2
            ;;
        # A bit better, but not that better
        "2")
            java -XX:StringTableSize=5087 -XX:+PrintStringTableStatistics -jar build/libs/string-interning.jar $2
            ;;
        # JVM's default
        "3")
            java -XX:+PrintStringTableStatistics -jar build/libs/string-interning.jar $2
            ;;
        # Better
        "4")
            java -XX:StringTableSize=2234129 -XX:+PrintStringTableStatistics -jar build/libs/string-interning.jar $2
            ;;
        # Huge One
        "5")
            java -XX:StringTableSize=8958797 -XX:+PrintStringTableStatistics -jar build/libs/string-interning.jar $2
            ;;
    esac
fi


<reponame>appleboy/nvm
#!/bin/bash

NVM_DIR="$HOME/.nvm"

if ! hash git 2>/dev/null; then
  echo >&2 "You need to install git - visit http://git-scm.com/downloads"
  echo >&2 "or, use install-gitless.sh instead."
  exit 1
fi

if [ -d "$NVM_DIR" ]; then
  echo "=> NVM is already installed in $NVM_DIR, trying to update"
  echo -ne "\r=> "
  cd $NVM_DIR && git pull
else
  # Cloning to $NVM_DIR
  git clone git://github.com/appleboy/nvm.git $NVM_DIR
fi

echo

# Detect profile file, .bash_profile has precedence over .profile
if [ ! -z "$1" ]; then
  PROFILE="$1"
else
  if [ -f "$HOME/.bash_profile" ]; then
	PROFILE="$HOME/.bash_profile"
  elif [ -f "$HOME/.profile" ]; then
	PROFILE="$HOME/.profile"
  fi
fi

SOURCE_STR="[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh"  # This loads NVM"

if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
  if [ -z $PROFILE ]; then
	echo "=> Profile not found. Tried $HOME/.bash_profile and $HOME/.profile"
  else
	echo "=> Profile $PROFILE not found"
  fi
  echo "=> Run this script again after running the following:"
  echo
  echo "\ttouch $HOME/.profile"
  echo
  echo "-- OR --"
  echo
  echo "=> Append the following line to the correct file yourself"
  echo
  echo "\t$SOURCE_STR"
  echo
  echo "=> Close and reopen your terminal afterwards to start using NVM"
  exit
fi

if ! grep -qc 'nvm.sh' $PROFILE; then
  echo "=> Appending source string to $PROFILE"
  echo "" >> "$PROFILE"
  echo $SOURCE_STR >> "$PROFILE"
else
  echo "=> Source string already in $PROFILE"
fi

echo "=> Close and reopen your terminal to start using NVM"


<gh_stars>0
git clone https://github.com/mozilla/pdf.js pdfjs-temp
cd pdfjs-temp
npm install
npm install gulp
./node_modules/.bin/gulp dist-pre
#cp ./build/dist/build/pdf.js ../lib/pdfjs/pdf.js
#cp ./build/dist/build/pdf.worker.js ../lib/pdfjs/pdf.worker.js
node -e 'var fs=require("fs");fs.writeFileSync("../lib/pdfjs/pdf.js",fs.readFileSync("./build/dist/build/pdf.js").toString().replace("verbosity = VerbosityLevel.WARNINGS","verbosity = VerbosityLevel.ERRORS").replace("node-ensure","./ensure.js"));process.exit()'
node -e 'var fs=require("fs");fs.writeFileSync("../lib/pdfjs/pdf.worker.js",fs.readFileSync("./build/dist/build/pdf.worker.js").toString().replace("verbosity = VerbosityLevel.WARNINGS","verbosity = VerbosityLevel.ERRORS"));process.exit()'
cp ./build/version.json ../lib/pdfjs/version.json
cp ./LICENSE ../lib/pdfjs/LICENSE
echo Used version
tail ./build/version.json
cd ..
rm -Rf pdfjs-temp