echo "set kubectl context to kubeflow"
kubectl config set-context $(kubectl config current-context) --namespace=kubeflow
echo "install kustomize"
opsys=linux  # or darwin, or windows
curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases/tags/v2.0.3 |\
  grep browser_download |\
  grep $opsys |\
  cut -d '"' -f 4 |\
  xargs curl -O -L
mv kustomize_*_${opsys}_amd64 kustomize
chmod u+x kustomize
export PATH=$PATH:$(pwd)

echo "rainers_example.sh TRAIN_NAME DOCKER_URL PVC_NAME"
DOCKER_URL=${2:-m1st3rb3an/kf_mnist_example1:dev}
TRAIN_NAME=${1:-'mnist-train-local-'$(date +%s)}
PVC_NAME=${3:-"workspace-rainer-kubeflow-example"}
echo "Using following parameter values"
echo "DOCKER_URL: "  $DOCKER_URL
echo "TRAIN_NAME: "  $TRAIN_NAME
echo "PVC_NAME: "  $PVC_NAME

echo "start customizing yamls"
#reseting training/local
git checkout training/local/*

cd training/local
kustomize edit add configmap mnist-map-training --from-literal=name=$TRAIN_NAME
kustomize edit set image training-image=$DOCKER_URL
../base/definition.sh --numPs 1 --numWorkers 2
kustomize edit add configmap mnist-map-training --from-literal=trainSteps=200
kustomize edit add configmap mnist-map-training --from-literal=batchSize=100
kustomize edit add configmap mnist-map-training --from-literal=learningRate=0.01
kustomize edit add configmap mnist-map-training --from-literal=pvcName=${PVC_NAME}
kustomize edit add configmap mnist-map-training --from-literal=pvcMountPath=/mnt
kustomize edit add configmap mnist-map-training --from-literal=modelDir=/mnt/${TRAIN_NAME}
kustomize edit add configmap mnist-map-training --from-literal=exportDir=/mnt/${TRAIN_NAME}/export

echo "Submitting training job to kubernetes cluster"
kustomize build . |kubectl apply -f -

echo "Querying tfjobs"
kubectl get tfjobs -o yaml $TRAIN_NAME

sleep 10s
echo "Tailing los"
kubectl logs --follow ${TRAIN_NAME}-chief-0


#!/bin/bash
#####		brook relay		初始化脚本

#更新软件包
apt-get -y update
#进入root目录
cd /root

#安装curl
apt-get -y install curl

#安装brook
curl -L http://soft.xiaoz.org/linux/rinetd -o /usr/bin/rinetd
chmod +x /usr/bin/rinetd
chmod +x /root/run.sh

#卸载curl
apt-get -y uninstall curl

echo '--------------------------------------'
echo 'rinetd installation success.'
echo '--------------------------------------'


<reponame>maulanakmal/mOS
#!/bin/zsh

sudo losetup /dev/loop0 ./artifacts/floppy.img
sudo bochs -qf bochsrc
sudo losetup -d /dev/loop0


#!/bin/bash

# This script will install the dependencies needed by the InterSCSimulator.

DEPENDENCIES_DIR='deps'
ROOT_DIR=`pwd`
RABBITMQ_URL='https://www.rabbitmq.com/releases/rabbitmq-erlang-client'
RABBITMQ_VERSION='3.6.11'

if [[ ! -e $DEPENDENCIES_DIR ]]; then
	mkdir -p $DEPENDENCIES_DIR
	cd $DEPENDENCIES_DIR
else
	echo "You already have the _build directory, if you want to reinstall it,"
	echo "please, remove it before run this script!"
	exit -5
fi

wget "$RABBITMQ_URL/v$RABBITMQ_VERSION/rabbit_common-$RABBITMQ_VERSION.ez" 2> /dev/null
wget "$RABBITMQ_URL/v$RABBITMQ_VERSION/amqp_client-$RABBITMQ_VERSION.ez" 2> /dev/null

if [[ $? != 0 ]]; then
	echo "Error during the download of .ez files!"
	exit -1
else
	echo "I: .ez files were downloaded"
fi

unzip -q "rabbit_common-$RABBITMQ_VERSION.ez"
unzip -q "amqp_client-$RABBITMQ_VERSION.ez"

if [[ $? != 0 ]]; then
	echo "Error during the descompress of .ez files!"
	exit -2
else
	echo "I: .ez files were descompressed"
fi

ln -s "amqp_client-$RABBITMQ_VERSION" amqp_client
cd amqp_client/include
ln -s "../../rabbit_common-$RABBITMQ_VERSION" rabbit_common

if [[ $? != 0 ]]; then
	echo "Error during the linkage!"
	exit -3
else
	echo "I: dependencies was linked"
fi

cd $ROOT_DIR


# ensure conda is properly initialised, such as by using the line below
# source /cm/shared/engaging/anaconda/2018.12/etc/profile.d/conda.sh
conda activate neuralsym

# cannot use too high LR, will diverge slowly (loss increases > 20)
# higher bs --> faster training (using CPU)
# 8 sec/epoch on 1 RTX2080Ti
sym_seed=$1
python train.py \
    --model 'Highway' \
    --expt_name "Highway_${sym_seed}_depth0_dim300_lr1e3_stop2_fac30_pat1" \
    --log_file "Highway_${sym_seed}_depth0_dim300_lr1e3_stop2_fac30_pat1" \
    --do_train \
    --do_test \
    --prodfps_prefix 50k_1000000dim_2rad_to_32681_prod_fps \
    --labels_prefix 50k_1000000dim_2rad_to_32681_labels \
    --csv_prefix 50k_1000000dim_2rad_to_32681_csv \
    --bs 300 \
    --bs_eval 300 \
    --random_seed ${sym_seed} \
    --learning_rate 1e-3 \
    --epochs 30 \
    --early_stop \
    --early_stop_patience 2 \
    --depth 0 \
    --hidden_size 300 \
    --lr_scheduler_factor 0.3 \
    --lr_scheduler_patience 1 \
    --checkpoint


#! /usr/bin/env sh

# Script to fetch all repos from the org
# Usage: ./download-assignment.sh <GitHub username> <GitHub Classroom Organization> <GH Classroom Assignent prefix> <Deadline as YYYY-MM-DDTHH:MM:SS> <git tag name>

GH_USER=$1
GH_ORG=$2
GH_REPO_PREFIX=$3
DEADLINE=$4
TAG_NAME=$5

./list-repos.py $GH_USER $GH_ORG $GH_REPO_PREFIX | xargs -n 1 sh -c "./clone-and-check.py \$0 $DEADLINE $TAG_NAME"


<reponame>pymole/sfxdx-test
#!/bin/bash

set -eu
set -o pipefail # If anything in a pipeline fails, the pipe's exit status is a failure
#set -x # Print all commands for debugging

declare -a KEY=(a b c d)

declare -A FROM=(
    [a]='-y --from a'
    [b]='-y --from b'
    [c]='-y --from c'
    [d]='-y --from d'
)

# This means we don't need to configure the cli since it uses the preconfigured cli in the docker.
# We define this as a function rather than as an alias because it has more flexible expansion behavior.
# In particular, it's not possible to dynamically expand aliases, but `tx_of` dynamically executes whatever
# we specify in its arguments.
function secretcli() {
    docker exec secretdev /usr/bin/secretcli "$@"
}

# Just like `echo`, but prints to stderr
function log() {
    echo "$@" >&2
}

# suppress all output to stdout for the command described in the arguments
function quiet() {
    "$@" >/dev/null
}

# suppress all output to stdout and stderr for the command described in the arguments
function silent() {
    "$@" >/dev/null 2>&1
}

# Pad the string in the first argument to 256 bytes, using spaces
function pad_space() {
    printf '%-256s' "$1"
}

function assert_eq() {
    set -e
    local left="$1"
    local right="$2"
    local message

    if [[ "$left" != "$right" ]]; then
        if [ -z ${3+x} ]; then
            local lineno="${BASH_LINENO[0]}"
            message="assertion failed on line $lineno - both sides differ. left: ${left@Q}, right: ${right@Q}"
        else
            message="$3"
        fi
        log "$message"
        return 1
    fi

    return 0
}

function assert_ne() {
    set -e
    local left="$1"
    local right="$2"
    local message

    if [[ "$left" == "$right" ]]; then
        if [ -z ${3+x} ]; then
            local lineno="${BASH_LINENO[0]}"
            message="assertion failed on line $lineno - both sides are equal. left: ${left@Q}, right: ${right@Q}"
        else
            message="$3"
        fi

        log "$message"
        return 1
    fi

    return 0
}

declare -A ADDRESS=(
    [a]="$(secretcli keys show --address a)"
    [b]="$(secretcli keys show --address b)"
    [c]="$(secretcli keys show --address c)"
    [d]="$(secretcli keys show --address d)"
)

declare -A VK=([a]='' [b]='' [c]='' [d]='')

# Generate a label for a contract with a given code id
# This just adds "contract_" before the code id.
function label_by_id() {
    local id="$1"
    echo "contract_$id"
}

# Keep polling the blockchain until the tx completes.
# The first argument is the tx hash.
# The second argument is a message that will be logged after every failed attempt.
# The tx information will be returned.
function wait_for_tx() {
    local tx_hash="$1"
    local message="$2"

    local result

    log "waiting on tx: $tx_hash"
    # secretcli will only print to stdout when it succeeds
    until result="$(secretcli query tx "$tx_hash" 2>/dev/null)"; do
        log "$message"
        sleep 1
    done

    # log out-of-gas events
    if quiet jq -e '.raw_log | startswith("execute contract failed: Out of gas: ") or startswith("out of gas:")' <<<"$result"; then
        log "$(jq -r '.raw_log' <<<"$result")"
    fi

    echo "$result"
}

# This is a wrapper around `wait_for_tx` that also decrypts the response,
# and returns a nonzero status code if the tx failed
function wait_for_compute_tx() {
    local tx_hash="$1"
    local message="$2"
    local return_value=0
    local result
    local decrypted

    result="$(wait_for_tx "$tx_hash" "$message")"
    # log "$result"
    if quiet jq -e '.logs == null' <<<"$result"; then
        return_value=1
    fi
    decrypted="$(secretcli query compute tx "$tx_hash")" || return
    log "$decrypted"
    echo "$decrypted"

    return "$return_value"
}

# If the tx failed, return a nonzero status code.
# The decrypted error or message will be echoed
function check_tx() {
    local tx_hash="$1"
    local result
    local return_value=0

    result="$(secretcli query tx "$tx_hash")"
    if quiet jq -e '.logs == null' <<<"$result"; then
        return_value=1
    fi
    decrypted="$(secretcli query compute tx "$tx_hash")" || return
    log "$decrypted"
    echo "$decrypted"

    return "$return_value"
}

# Extract the tx_hash from the output of the command
function tx_of() {
    "$@" | jq -r '.txhash'
}

# Extract the output_data_as_string from the output of the command
function data_of() {
    "$@" | jq -r '.output_data_as_string'
}

function get_generic_err() {
    jq -r '.output_error.generic_err.msg' <<<"$1"
}

# Send a compute transaction and return the tx hash.
# All arguments to this function are passed directly to `secretcli tx compute execute`.
function compute_execute() {
    tx_of secretcli tx compute execute "$@"
}

# Send a query to the contract.
# All arguments to this function are passed directly to `secretcli query compute query`.
function compute_query() {
    secretcli query compute query "$@"
}

function upload_code() {
    set -e
    local directory="$1"
    local tx_hash
    local code_id

    tx_hash="$(tx_of secretcli tx compute store "code/$directory/contract.wasm.gz" ${FROM[a]} --gas 10000000)"
    code_id="$(
        wait_for_tx "$tx_hash" 'waiting for contract upload' |
            jq -r '.logs[0].events[0].attributes[] | select(.key == "code_id") | .value'
    )"

    log "uploaded contract #$code_id"

    echo "$code_id"
}

function instantiate() {
    set -e
    local code_id="$1"
    local init_msg="$2"

    log 'sending init message:'
    log "${init_msg@Q}"

    local tx_hash
    tx_hash="$(tx_of secretcli tx compute instantiate "$code_id" "$init_msg" --label "$(label_by_id "$code_id")" ${FROM[a]} --gas 10000000)"
    wait_for_tx "$tx_hash" 'waiting for init to complete'
}

# This function uploads and instantiates a contract, and returns the new contract's address
function create_contract() {
    set -e
    local dir="$1"
    local init_msg="$2"

    local code_id
    code_id="$(upload_code "$dir")"

    local init_result
    init_result="$(instantiate "$code_id" "$init_msg")"

    if quiet jq -e '.logs == null' <<<"$init_result"; then
        log "$(secretcli query compute tx "$(jq -r '.txhash' <<<"$init_result")")"
        return 1
    fi

    jq -r '.logs[0].events[0].attributes[] | select(.key == "contract_address") | .value' <<<"$init_result"
}

function deposit() {
    set -e
    local contract_addr="$1"
    local key="$2"
    local amount="$3"

    local deposit_message='{"deposit":{"padding":":::::::::::::::::"}}'
    local tx_hash
    local deposit_response
    tx_hash="$(compute_execute "$contract_addr" "$deposit_message" --amount "${amount}uscrt" ${FROM[$key]} --gas 150000)"
    deposit_response="$(data_of wait_for_compute_tx "$tx_hash" "waiting for deposit to \"$key\" to process")"
    assert_eq "$deposit_response" "$(pad_space '{"deposit":{"status":"success"}}')"
    log "deposited ${amount}uscrt to \"$key\" successfully"
    echo "$tx_hash"
}

function mint() {
    set -e
    local contract_addr="$1"
    local key="$2"
    local recipient="$3"
    local amount="$4"

    local mint_message='{"mint":{"recipient":"'"$recipient"'","amount":"'"$amount"'","padding":":::::::::::::::::"}}'
    local tx_hash
    local deposit_response
    tx_hash="$(compute_execute "$contract_addr" "$mint_message" ${FROM[$key]} --gas 151000)"
    echo "$tx_hash"
    deposit_response="$(data_of wait_for_compute_tx "$tx_hash" "waiting for mint to \"$recipient\" to process")"
    assert_eq "$deposit_response" "$(pad_space '{"mint":{"status":"success"}}')"
    log "minted ${amount}uscrt for \"$recipient\" successfully"
}

function burn() {
    set -e
    local contract_addr="$1"
    local key="$2"
    local amount="$3"

    local burn_message='{"burn":{"amount":"'"$amount"'"}}'
    local tx_hash
    local burn_response
    tx_hash="$(compute_execute "$contract_addr" "$burn_message" ${FROM[$key]} --gas 150000)"
    echo "$tx_hash"
    burn_response="$(data_of wait_for_compute_tx "$tx_hash" "waiting for burn for \"$key\" to process")"
    log "$burn_response"
    assert_eq "$burn_response" "$(pad_space '{"burn":{"status":"success"}}')"
    log "burned ${amount}uscrt for \"$key\" successfully"
}

function get_balance() {
    set -e
    local contract_addr="$1"
    local key="$2"

    log "querying balance for \"$key\""
    local balance_query='{"balance":{"address":"'"${ADDRESS[$key]}"'","key":"'"${VK[$key]}"'"}}'
    local balance_response
    balance_response="$(compute_query "$contract_addr" "$balance_query")"
    log "balance response was: $balance_response"
    jq -r '.balance.amount' <<<"$balance_response"
}

# Redeem some SCRT from an account
# As you can see, verifying this is happening correctly requires a lot of code
# so I separated it to its own function, because it's used several times.
function redeem() {
    set -e
    local contract_addr="$1"
    local key="$2"
    local amount="$3"

    local redeem_message
    local tx_hash
    local redeem_tx
    local transfer_attributes
    local redeem_response

    log "redeeming \"$key\""
    redeem_message='{"redeem":{"amount":"'"$amount"'"}}'
    tx_hash="$(compute_execute "$contract_addr" "$redeem_message" ${FROM[$key]} --gas 150000)"
    redeem_tx="$(wait_for_tx "$tx_hash" "waiting for redeem from \"$key\" to process")"
    transfer_attributes="$(jq -r '.logs[0].events[] | select(.type == "transfer") | .attributes' <<<"$redeem_tx")"
    assert_eq "$(jq -r '.[] | select(.key == "recipient") | .value' <<<"$transfer_attributes")" "${ADDRESS[$key]}"
    assert_eq "$(jq -r '.[] | select(.key == "amount") | .value' <<<"$transfer_attributes")" "${amount}uscrt"
    log "redeem response for \"$key\" returned ${amount}uscrt"

    redeem_response="$(data_of check_tx "$tx_hash")"
    assert_eq "$redeem_response" "$(pad_space '{"redeem":{"status":"success"}}')"
    log "redeemed ${amount} from \"$key\" successfully"
    echo "$tx_hash"
}

function get_token_info() {
    set -e
    local contract_addr="$1"

    local token_info_query='{"token_info":{}}'
    compute_query "$contract_addr" "$token_info_query"
}

function increase_allowance() {
    set -e
    local contract_addr="$1"
    local owner_key="$2"
    local spender_key="$3"
    local amount="$4"

    local owner_address="${ADDRESS[$owner_key]}"
    local spender_address="${ADDRESS[$spender_key]}"
    local allowance_message='{"increase_allowance":{"spender":"'"$spender_address"'","amount":"'"$amount"'"}}'
    local allowance_response

    tx_hash="$(compute_execute "$contract_addr" "$allowance_message" ${FROM[$owner_key]} --gas 150000)"
    allowance_response="$(data_of wait_for_compute_tx "$tx_hash" "waiting for the increase of \"$spender_key\"'s allowance to \"$owner_key\"'s funds to process")"
    assert_eq "$(jq -r '.increase_allowance.spender' <<<"$allowance_response")" "$spender_address"
    assert_eq "$(jq -r '.increase_allowance.owner' <<<"$allowance_response")" "$owner_address"
    jq -r '.increase_allowance.allowance' <<<"$allowance_response"
    log "Increased allowance given to \"$spender_key\" from \"$owner_key\" by ${amount}uscrt successfully"
}

function decrease_allowance() {
    set -e
    local contract_addr="$1"
    local owner_key="$2"
    local spender_key="$3"
    local amount="$4"

    local owner_address="${ADDRESS[$owner_key]}"
    local spender_address="${ADDRESS[$spender_key]}"
    local allowance_message='{"decrease_allowance":{"spender":"'"$spender_address"'","amount":"'"$amount"'"}}'
    local allowance_response

    tx_hash="$(compute_execute "$contract_addr" "$allowance_message" ${FROM[$owner_key]} --gas 150000)"
    allowance_response="$(data_of wait_for_compute_tx "$tx_hash" "waiting for the decrease of \"$spender_key\"'s allowance to \"$owner_key\"'s funds to process")"
    assert_eq "$(jq -r '.decrease_allowance.spender' <<<"$allowance_response")" "$spender_address"
    assert_eq "$(jq -r '.decrease_allowance.owner' <<<"$allowance_response")" "$owner_address"
    jq -r '.decrease_allowance.allowance' <<<"$allowance_response"
    log "Decreased allowance given to \"$spender_key\" from \"$owner_key\" by ${amount}uscrt successfully"
}

function get_allowance() {
    set -e
    local contract_addr="$1"
    local owner_key="$2"
    local spender_key="$3"

    log "querying allowance given to \"$spender_key\" by \"$owner_key\""
    local owner_address="${ADDRESS[$owner_key]}"
    local spender_address="${ADDRESS[$spender_key]}"
    local allowance_query='{"allowance":{"spender":"'"$spender_address"'","owner":"'"$owner_address"'","key":"'"${VK[$owner_key]}"'"}}'
    local allowance_response
    allowance_response="$(compute_query "$contract_addr" "$allowance_query")"
    log "allowance response was: $allowance_response"
    assert_eq "$(jq -r '.allowance.spender' <<<"$allowance_response")" "$spender_address"
    assert_eq "$(jq -r '.allowance.owner' <<<"$allowance_response")" "$owner_address"
    jq -r '.allowance.allowance' <<<"$allowance_response"
}

# This function is the same as above, but it also checks the expiration
function check_allowance() {
    set -e
    local contract_addr="$1"
    local owner_key="$2"
    local spender_key="$3"
    local expiration="$4"

    log "querying allowance given to \"$spender_key\" by \"$owner_key\""
    local owner_address="${ADDRESS[$owner_key]}"
    local spender_address="${ADDRESS[$spender_key]}"
    local allowance_query='{"allowance":{"spender":"'"$spender_address"'","owner":"'"$owner_address"'","key":"'"${VK[$owner_key]}"'"}}'
    local allowance_response
    allowance_response="$(compute_query "$contract_addr" "$allowance_query")"
    log "allowance response was: $allowance_response"
    assert_eq "$(jq -r '.allowance.spender' <<<"$allowance_response")" "$spender_address"
    assert_eq "$(jq -r '.allowance.owner' <<<"$allowance_response")" "$owner_address"
    assert_eq "$(jq -r '.allowance.expiration' <<<"$allowance_response")" "$expiration"
    jq -r '.allowance.allowance' <<<"$allowance_response"
}

function log_test_header() {
    log " ########### Starting ${FUNCNAME[1]} ###############################################################################################################################################"
}

function test_viewing_key() {
    set -e
    local contract_addr="$1"

    log_test_header

    # common variables
    local result
    local tx_hash

    # query balance. Should fail.
    local wrong_key
    wrong_key="$(xxd -ps <<<'wrong-key')"
    local balance_query
    local expected_error='{"viewing_key_error":{"msg":"Wrong viewing key for this address or viewing key not set"}}'
    for key in "${KEY[@]}"; do
        log "querying balance for \"$key\" with wrong viewing key"
        balance_query='{"balance":{"address":"'"${ADDRESS[$key]}"'","key":"'"$wrong_key"'"}}'
        result="$(compute_query "$contract_addr" "$balance_query")"
        assert_eq "$result" "$expected_error"
    done

    # Create viewing keys
    local create_viewing_key_message='{"create_viewing_key":{"entropy":"MyPassword123"}}'
    local viewing_key_response
    for key in "${KEY[@]}"; do
        log "creating viewing key for \"$key\""
        tx_hash="$(compute_execute "$contract_addr" "$create_viewing_key_message" ${FROM[$key]} --gas 1400000)"
        viewing_key_response="$(data_of wait_for_compute_tx "$tx_hash" "waiting for viewing key for \"$key\" to be created")"
        VK[$key]="$(jq -er '.create_viewing_key.key' <<<"$viewing_key_response")"
        log "viewing key for \"$key\" set to ${VK[$key]}"
        if [[ "${VK[$key]}" =~ ^api_key_ ]]; then
            log "viewing key \"$key\" seems valid"
        else
            log 'viewing key is invalid'
            return 1
        fi
    done

    # Check that all viewing keys are different despite using the same entropy
    assert_ne "${VK[a]}" "${VK[b]}"
    assert_ne "${VK[b]}" "${VK[c]}"
    assert_ne "${VK[c]}" "${VK[d]}"

    # query balance. Should succeed.
    local balance_query
    for key in "${KEY[@]}"; do
        balance_query='{"balance":{"address":"'"${ADDRESS[$key]}"'","key":"'"${VK[$key]}"'"}}'
        log "querying balance for \"$key\" with correct viewing key"
        result="$(compute_query "$contract_addr" "$balance_query")"
        if ! silent jq -e '.balance.amount | tonumber' <<<"$result"; then
            log "Balance query returned unexpected response: ${result@Q}"
            return 1
        fi
    done

    # Change viewing keys
    local vk2_a

    log 'creating new viewing key for "a"'
    tx_hash="$(compute_execute "$contract_addr" "$create_viewing_key_message" ${FROM[a]} --gas 1400000)"
    viewing_key_response="$(data_of wait_for_compute_tx "$tx_hash" 'waiting for viewing key for "a" to be created')"
    vk2_a="$(jq -er '.create_viewing_key.key' <<<"$viewing_key_response")"
    log "viewing key for \"a\" set to $vk2_a"
    assert_ne "${VK[a]}" "$vk2_a"

    # query balance with old keys. Should fail.
    log 'querying balance for "a" with old viewing key'
    local balance_query_a='{"balance":{"address":"'"${ADDRESS[a]}"'","key":"'"${VK[a]}"'"}}'
    result="$(compute_query "$contract_addr" "$balance_query_a")"
    assert_eq "$result" "$expected_error"

    # query balance with new keys. Should succeed.
    log 'querying balance for "a" with new viewing key'
    balance_query_a='{"balance":{"address":"'"${ADDRESS[a]}"'","key":"'"$vk2_a"'"}}'
    result="$(compute_query "$contract_addr" "$balance_query_a")"
    if ! silent jq -e '.balance.amount | tonumber' <<<"$result"; then
        log "Balance query returned unexpected response: ${result@Q}"
        return 1
    fi

    # Set the vk for "a" to the original vk
    log 'setting the viewing key for "a" back to the first one'
    local set_viewing_key_message='{"set_viewing_key":{"key":"'"${VK[a]}"'"}}'
    tx_hash="$(compute_execute "$contract_addr" "$set_viewing_key_message" ${FROM[a]} --gas 1400000)"
    viewing_key_response="$(data_of wait_for_compute_tx "$tx_hash" 'waiting for viewing key for "a" to be set')"
    assert_eq "$viewing_key_response" "$(pad_space '{"set_viewing_key":{"status":"success"}}')"

    # try to use the new key - should fail
    log 'querying balance for "a" with new viewing key'
    balance_query_a='{"balance":{"address":"'"${ADDRESS[a]}"'","key":"'"$vk2_a"'"}}'
    result="$(compute_query "$contract_addr" "$balance_query_a")"
    assert_eq "$result" "$expected_error"

    # try to use the old key - should succeed
    log 'querying balance for "a" with old viewing key'
    balance_query_a='{"balance":{"address":"'"${ADDRESS[a]}"'","key":"'"${VK[a]}"'"}}'
    result="$(compute_query "$contract_addr" "$balance_query_a")"
    if ! silent jq -e '.balance.amount | tonumber' <<<"$result"; then
        log "Balance query returned unexpected response: ${result@Q}"
        return 1
    fi
}

function test_deposit() {
    set -e
    local contract_addr="$1"

    log_test_header

    local tx_hash

    local -A deposits=([a]=1000000 [b]=2000000 [c]=3000000 [d]=4000000)
    local tx_hash
    local native_tx
    local timestamp
    local block_height
    for key in "${KEY[@]}"; do
        tx_hash="$(deposit "$contract_addr" "$key" "${deposits[$key]}")"
        native_tx="$(secretcli q tx "$tx_hash")"
        timestamp="$(unix_time_of_tx "$native_tx")"
        block_height="$(jq -r '.height' <<<"$native_tx")"
        quiet check_latest_tx_history_deposit "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" "${deposits[$key]}" "$timestamp" "$block_height"
    done

    # Query the balances of the accounts and make sure they have the right balances.
    for key in "${KEY[@]}"; do
        assert_eq "$(get_balance "$contract_addr" "$key")" "${deposits[$key]}"
    done

    # Try to overdraft
    local redeem_message
    local overdraft
    local redeem_response
    for key in "${KEY[@]}"; do
        overdraft="$((deposits[$key] + 1))"
        redeem_message='{"redeem":{"amount":"'"$overdraft"'"}}'
        tx_hash="$(compute_execute "$contract_addr" "$redeem_message" ${FROM[$key]} --gas 150000)"
        # Notice the `!` before the command - it is EXPECTED to fail.
        ! redeem_response="$(wait_for_compute_tx "$tx_hash" "waiting for overdraft from \"$key\" to process")"
        log "trying to overdraft from \"$key\" was rejected"
        assert_eq \
            "$(get_generic_err "$redeem_response")" \
            "insufficient funds to redeem: balance=${deposits[$key]}, required=$overdraft"
    done

    # Withdraw Everything
    local tx_hash
    local native_tx
    local timestamp
    local block_height
    for key in "${KEY[@]}"; do
        tx_hash="$(redeem "$contract_addr" "$key" "${deposits[$key]}")"
        native_tx="$(secretcli q tx "$tx_hash")"
        timestamp="$(unix_time_of_tx "$native_tx")"
        block_height="$(jq -r '.height' <<<"$native_tx")"
        quiet check_latest_tx_history_redeem "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" "${deposits[$key]}" "$timestamp" "$block_height"
    done

    # Check the balances again. They should all be empty
    for key in "${KEY[@]}"; do
        assert_eq "$(get_balance "$contract_addr" "$key")" 0
    done
}

function unix_time_of_tx() {
    set -e
    local tx="$1"

    date -d "$(jq -r '.timestamp' <<<"$tx")" '+%s'
}

function get_transfer_history() {
    set -e
    local contract_addr="$1"
    local account="$2"
    local viewing_key="$3"
    local page_size="$4"
    local page="$5"

    local transfer_history_query
    local transfer_history_response
    transfer_history_query='{"transfer_history":{"address":"'"$account"'","key":"'"$viewing_key"'","page_size":'"$page_size"',"page":'"$page"'}}'
    transfer_history_response="$(compute_query "$contract_addr" "$transfer_history_query")"
    log "$transfer_history_response"
    # There's no good way of tracking the exact expected value,
    # so we just check that the `total` field is a number
    quiet jq -e '.transfer_history.total | numbers' <<<"$transfer_history_response"
    jq -r '.transfer_history.txs' <<<"$transfer_history_response"
}

# This function checks that the latest tx history for the account matches
# the expected parameters.
# The id of the tx is printed out.
function check_latest_transfer_history() {
    set -e
    local contract_addr="$1"
    local account="$2"
    local viewing_key="$3"
    local sender="$4"
    local from="$5"
    local receiver="$6"
    local amount="$7"
    local block_time="$8"
    local block_height="$9"

    local txs
    local tx

    txs="$(get_transfer_history "$contract_addr" "$account" "$viewing_key" 1 0)"
    silent jq -e 'length == 1' <<<"$txs" # just make sure we're not getting a weird response
    tx="$(jq -r '.[0]' <<<"$txs")"
    assert_eq "$(jq -r '.sender' <<<"$tx")" "$sender"
    assert_eq "$(jq -r '.from' <<<"$tx")" "$from"
    assert_eq "$(jq -r '.receiver' <<<"$tx")" "$receiver"
    assert_eq "$(jq -r '.coins.amount' <<<"$tx")" "$amount"
    assert_eq "$(jq -r '.coins.denom' <<<"$tx")" 'SSCRT'
    assert_eq "$(jq -r '.block_time' <<<"$tx")" "$block_time"
    assert_eq "$(jq -r '.block_height' <<<"$tx")" "$block_height"

    jq -r '.id' <<<"$tx"
}

function get_transaction_history() {
    set -e
    local contract_addr="$1"
    local account="$2"
    local viewing_key="$3"
    local page_size="$4"
    local page="$5"

    local transaction_history_query
    local transaction_history_response
    transaction_history_query='{"transaction_history":{"address":"'"$account"'","key":"'"$viewing_key"'","page_size":'"$page_size"',"page":'"$page"'}}'
    transaction_history_response="$(compute_query "$contract_addr" "$transaction_history_query")"
    log "$transaction_history_response"
    # There's no good way of tracking the exact expected value,
    # so we just check that the `total` field is a number
    quiet jq -e '.transaction_history.total | numbers' <<<"$transaction_history_response"
    jq -r '.transaction_history.txs' <<<"$transaction_history_response"
}

function check_latest_tx_history_transfer() {
    set -e
    local contract_addr="$1"
    local account="$2"
    local viewing_key="$3"
    local sender="$4"
    local from="$5"
    local recipient="$6"
    local amount="$7"
    local block_time="$8"
    local block_height="$9"

    local txs
    local tx

    txs="$(get_transaction_history "$contract_addr" "$account" "$viewing_key" 1 0)"
    silent jq -e 'length == 1' <<<"$txs" # just make sure we're not getting a weird response
    tx="$(jq -r '.[0]' <<<"$txs")"
    assert_eq "$(jq -r '.action.transfer.sender' <<<"$tx")" "$sender"
    assert_eq "$(jq -r '.action.transfer.from' <<<"$tx")" "$from"
    assert_eq "$(jq -r '.action.transfer.recipient' <<<"$tx")" "$recipient"
    assert_eq "$(jq -r '.coins.amount' <<<"$tx")" "$amount"
    assert_eq "$(jq -r '.coins.denom' <<<"$tx")" 'SSCRT'
    assert_eq "$(jq -r '.block_time' <<<"$tx")" "$block_time"
    assert_eq "$(jq -r '.block_height' <<<"$tx")" "$block_height"

    jq -r '.id' <<<"$tx"
}

function check_latest_tx_history_mint() {
    set -e
    local contract_addr="$1"
    local account="$2"
    local viewing_key="$3"
    local minter="$4"
    local recipient="$5"
    local amount="$6"
    local block_time="$7"
    local block_height="$8"

    local txs
    local tx

    txs="$(get_transaction_history "$contract_addr" "$account" "$viewing_key" 1 0)"
    silent jq -e 'length == 1' <<<"$txs" # just make sure we're not getting a weird response
    tx="$(jq -r '.[0]' <<<"$txs")"
    assert_eq "$(jq -r '.action.mint.minter' <<<"$tx")" "$minter"
    assert_eq "$(jq -r '.action.mint.recipient' <<<"$tx")" "$recipient"
    assert_eq "$(jq -r '.coins.amount' <<<"$tx")" "$amount"
    assert_eq "$(jq -r '.coins.denom' <<<"$tx")" 'SSCRT'
    assert_eq "$(jq -r '.block_time' <<<"$tx")" "$block_time"
    assert_eq "$(jq -r '.block_height' <<<"$tx")" "$block_height"

    jq -r '.id' <<<"$tx"
}

function check_latest_tx_history_burn() {
    set -e
    local contract_addr="$1"
    local account="$2"
    local viewing_key="$3"
    local burner="$4"
    local owner="$5"
    local amount="$6"
    local block_time="$7"
    local block_height="$8"

    local txs
    local tx

    txs="$(get_transaction_history "$contract_addr" "$account" "$viewing_key" 1 0)"
    silent jq -e 'length == 1' <<<"$txs" # just make sure we're not getting a weird response
    tx="$(jq -r '.[0]' <<<"$txs")"
    assert_eq "$(jq -r '.action.burn.burner' <<<"$tx")" "$burner"
    assert_eq "$(jq -r '.action.burn.owner' <<<"$tx")" "$owner"
    assert_eq "$(jq -r '.coins.amount' <<<"$tx")" "$amount"
    assert_eq "$(jq -r '.coins.denom' <<<"$tx")" 'SSCRT'
    assert_eq "$(jq -r '.block_time' <<<"$tx")" "$block_time"
    assert_eq "$(jq -r '.block_height' <<<"$tx")" "$block_height"

    jq -r '.id' <<<"$tx"
}

function check_latest_tx_history_deposit() {
    set -e
    local contract_addr="$1"
    local account="$2"
    local viewing_key="$3"
    local amount="$4"
    local block_time="$5"
    local block_height="$6"

    local txs
    local tx

    txs="$(get_transaction_history "$contract_addr" "$account" "$viewing_key" 1 0)"
    silent jq -e 'length == 1' <<<"$txs" # just make sure we're not getting a weird response
    tx="$(jq -r '.[0]' <<<"$txs")"
    quiet jq -e '.action.deposit | objects' <<<"$tx"
    assert_eq "$(jq -r '.coins.amount' <<<"$tx")" "$amount"
    assert_eq "$(jq -r '.coins.denom' <<<"$tx")" 'uscrt'
    assert_eq "$(jq -r '.block_time' <<<"$tx")" "$block_time"
    assert_eq "$(jq -r '.block_height' <<<"$tx")" "$block_height"

    jq -r '.id' <<<"$tx"
}

function check_latest_tx_history_redeem() {
    set -e
    local contract_addr="$1"
    local account="$2"
    local viewing_key="$3"
    local amount="$4"
    local block_time="$5"
    local block_height="$6"

    local txs
    local tx

    txs="$(get_transaction_history "$contract_addr" "$account" "$viewing_key" 1 0)"
    silent jq -e 'length == 1' <<<"$txs" # just make sure we're not getting a weird response
    tx="$(jq -r '.[0]' <<<"$txs")"
    quiet jq -e '.action.redeem | objects' <<<"$tx"
    assert_eq "$(jq -r '.coins.amount' <<<"$tx")" "$amount"
    assert_eq "$(jq -r '.coins.denom' <<<"$tx")" 'SSCRT'
    assert_eq "$(jq -r '.block_time' <<<"$tx")" "$block_time"
    assert_eq "$(jq -r '.block_height' <<<"$tx")" "$block_height"

    jq -r '.id' <<<"$tx"
}

function test_transfer() {
    set -e
    local contract_addr="$1"

    log_test_header

    local tx_hash

    # Check "a" and "b" don't have any funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 0
    assert_eq "$(get_balance "$contract_addr" 'b')" 0

    # Deposit to "a"
    quiet deposit "$contract_addr" 'a' 1000000

    # Try to transfer more than "a" has
    log 'transferring funds from "a" to "b", but more than "a" has'
    local transfer_message='{"transfer":{"recipient":"'"${ADDRESS[b]}"'","amount":"1000001"}}'
    local transfer_response
    tx_hash="$(compute_execute "$contract_addr" "$transfer_message" ${FROM[a]} --gas 150000)"
    # Notice the `!` before the command - it is EXPECTED to fail.
    ! transfer_response="$(wait_for_compute_tx "$tx_hash" 'waiting for transfer from "a" to "b" to process')"
    log "trying to overdraft from \"a\" to transfer to \"b\" was rejected"
    assert_eq "$(get_generic_err "$transfer_response")" "insufficient funds: balance=1000000, required=1000001"

    # Check both a and b, that their last transaction is not for 1000001 uscrt
    local txs
    for key in a b; do
        log "querying the transfer history of \"$key\""
        txs="$(get_transfer_history "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" 1 0)"
        silent jq -e 'length <= 1' <<<"$txs" # just make sure we're not getting a weird response
        if silent jq -e 'length == 1' <<<"$txs"; then
            assert_ne "$(jq -r '.[0].coins.amount' <<<"$txs")" 1000001
        fi
    done

    # Transfer from "a" to "b"
    log 'transferring funds from "a" to "b"'
    local transfer_message='{"transfer":{"recipient":"'"${ADDRESS[b]}"'","amount":"400000"}}'
    local transfer_response
    tx_hash="$(compute_execute "$contract_addr" "$transfer_message" ${FROM[a]} --gas 200000)"
    transfer_response="$(data_of wait_for_compute_tx "$tx_hash" 'waiting for transfer from "a" to "b" to process')"
    assert_eq "$transfer_response" "$(pad_space '{"transfer":{"status":"success"}}')"

    local native_tx
    native_tx="$(secretcli q tx "$tx_hash")"
    local timestamp
    timestamp="$(unix_time_of_tx "$native_tx")"
    local block_height
    block_height="$(jq -r '.height' <<<"$native_tx")"

    # Check for both "a" and "b" that they recorded the transfer
    local -A tx_ids
    local tx_id
    for key in a b; do
        log "querying the transfer history of \"$key\""
        tx_ids[$key]="$(
            check_latest_transfer_history "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" \
                "${ADDRESS[a]}" "${ADDRESS[a]}" "${ADDRESS[b]}" 400000 "$timestamp" "$block_height"
        )"
        tx_id="$(
            check_latest_tx_history_transfer "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" \
                "${ADDRESS[a]}" "${ADDRESS[a]}" "${ADDRESS[b]}" 400000 "$timestamp" "$block_height"
        )"
        assert_eq "$tx_id" "${tx_ids[$key]}"
    done

    assert_eq "${tx_ids[a]}" "${tx_ids[b]}"
    log 'The transfer was recorded correctly in the transaction history'

    # Check that "a" has fewer funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 600000

    # Check that "b" has the funds that "a" deposited
    assert_eq "$(get_balance "$contract_addr" 'b')" 400000

    # Redeem both accounts
    redeem "$contract_addr" a 600000
    redeem "$contract_addr" b 400000
    # Send the funds back
    quiet secretcli tx send b "${ADDRESS[a]}" 400000uscrt -y -b block
}

RECEIVER_ADDRESS=''

function create_receiver_contract() {
    set -e
    local init_msg

    if [[ "$RECEIVER_ADDRESS" != '' ]]; then
        log 'Receiver contract already exists'
        echo "$RECEIVER_ADDRESS"
        return 0
    fi

    init_msg='{"count":0}'
    RECEIVER_ADDRESS="$(create_contract 'tests/example-receiver' "$init_msg")"

    log "uploaded receiver contract to $RECEIVER_ADDRESS"
    echo "$RECEIVER_ADDRESS"
}

# This function exists so that we can reset the state as much as possible between different tests
function redeem_receiver() {
    set -e
    local receiver_addr="$1"
    local snip20_addr="$2"
    local to_addr="$3"
    local amount="$4"

    local tx_hash
    local redeem_tx
    local transfer_attributes

    log 'fetching snip20 hash'
    local snip20_hash
    snip20_hash="$(secretcli query compute contract-hash "$snip20_addr")"

    local redeem_message='{"redeem":{"addr":"'"$snip20_addr"'","hash":"'"${snip20_hash:2}"'","to":"'"$to_addr"'","amount":"'"$amount"'"}}'
    tx_hash="$(compute_execute "$receiver_addr" "$redeem_message" ${FROM[a]} --gas 300000)"
    redeem_tx="$(wait_for_tx "$tx_hash" "waiting for redeem from receiver at \"$receiver_addr\" to process")"
    # log "$redeem_tx"
    transfer_attributes="$(jq -r '.logs[0].events[] | select(.type == "transfer") | .attributes' <<<"$redeem_tx")"
    assert_eq "$(jq -r '.[] | select(.key == "recipient") | .value' <<<"$transfer_attributes")" "$receiver_addr"$'\n'"$to_addr"
    assert_eq "$(jq -r '.[] | select(.key == "amount") | .value' <<<"$transfer_attributes")" "${amount}uscrt"$'\n'"${amount}uscrt"
    log "redeem response for \"$receiver_addr\" returned ${amount}uscrt"
}

function register_receiver() {
    set -e
    local receiver_addr="$1"
    local snip20_addr="$2"

    local tx_hash

    log 'fetching snip20 hash'
    local snip20_hash
    snip20_hash="$(secretcli query compute contract-hash "$snip20_addr")"

    log 'registering with snip20'
    local register_message='{"register":{"reg_addr":"'"$snip20_addr"'","reg_hash":"'"${snip20_hash:2}"'"}}'
    tx_hash="$(compute_execute "$receiver_addr" "$register_message" ${FROM[a]} --gas 200000)"
    # we throw away the output since we know it's empty
    local register_tx
    register_tx="$(wait_for_compute_tx "$tx_hash" 'Waiting for receiver registration')"
    assert_eq \
        "$(jq -r '.output_log[] | select(.type == "wasm") | .attributes[] | select(.key == "register_status") | .value' <<<"$register_tx")" \
        'success'
    log 'receiver registered successfully'
}

function test_send() {
    set -e
    local contract_addr="$1"

    log_test_header

    local receiver_addr
    receiver_addr="$(create_receiver_contract)"
    # receiver_addr='secret17k8qt6aqd7eee3fawmtvy4vu6teqx8d7mdm49x'
    register_receiver "$receiver_addr" "$contract_addr"

    local tx_hash

    # Check "a" and "b" don't have any funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 0
    assert_eq "$(get_balance "$contract_addr" 'b')" 0

    # Deposit to "a"
    quiet deposit "$contract_addr" 'a' 1000000

    # Try to send more than "a" has
    log 'sending funds from "a" to "b", but more than "a" has'
    local send_message='{"send":{"recipient":"'"${ADDRESS[b]}"'","amount":"1000001"}}'
    local send_response
    tx_hash="$(compute_execute "$contract_addr" "$send_message" ${FROM[a]} --gas 150000)"
    # Notice the `!` before the command - it is EXPECTED to fail.
    ! send_response="$(wait_for_compute_tx "$tx_hash" 'waiting for send from "a" to "b" to process')"
    log "trying to overdraft from \"a\" to send to \"b\" was rejected"
    assert_eq "$(get_generic_err "$send_response")" "insufficient funds: balance=1000000, required=1000001"

    # Check both a and b, that their last transaction is not for 1000001 uscrt
    local txs
    for key in a b; do
        log "querying the transfer history of \"$key\""
        txs="$(get_transfer_history "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" 1 0)"
        silent jq -e 'length <= 1' <<<"$txs" # just make sure we're not getting a weird response
        if silent jq -e 'length == 1' <<<"$txs"; then
            assert_ne "$(jq -r '.[0].coins.amount' <<<"$txs")" 1000001
        fi
    done

    # Query receiver state before Send
    local receiver_state
    local receiver_state_query='{"get_count":{}}'
    receiver_state="$(compute_query "$receiver_addr" "$receiver_state_query")"
    local original_count
    original_count="$(jq -r '.count' <<<"$receiver_state")"

    # Send from "a" to the receiver with message to the Receiver
    log 'sending funds from "a" to the Receiver, with message to the Receiver'
    local receiver_msg='{"increment":{}}'
    receiver_msg="$(base64 <<<"$receiver_msg")"
    local send_message='{"send":{"recipient":"'"$receiver_addr"'","amount":"400000","msg":"'$receiver_msg'"}}'
    local send_response
    tx_hash="$(compute_execute "$contract_addr" "$send_message" ${FROM[a]} --gas 300000)"
    send_response="$(wait_for_compute_tx "$tx_hash" 'waiting for send from "a" to the Receiver to process')"
    assert_eq \
        "$(jq -r '.output_log[0].attributes[] | select(.key == "count") | .value' <<<"$send_response")" \
        "$((original_count + 1))"
    log 'received send response'

    local native_tx
    native_tx="$(secretcli q tx "$tx_hash")"
    local timestamp
    timestamp="$(unix_time_of_tx "$native_tx")"
    local block_height
    block_height="$(jq -r '.height' <<<"$native_tx")"

    # Check that the receiver got the message
    log 'checking whether state was updated in the receiver'
    receiver_state_query='{"get_count":{}}'
    receiver_state="$(compute_query "$receiver_addr" "$receiver_state_query")"
    local new_count
    new_count="$(jq -r '.count' <<<"$receiver_state")"
    assert_eq "$((original_count + 1))" "$new_count"
    log 'receiver contract received the message'

    # Check that "a" recorded the transfer
    log 'querying the transfer history of "a"'
    local tx_id1
    local tx_id2
    tx_id1="$(check_latest_transfer_history "$contract_addr" "${ADDRESS[a]}" "${VK[a]}" \
        "${ADDRESS[a]}" "${ADDRESS[a]}" "$receiver_addr" 400000 "$timestamp" "$block_height")"
    tx_id2="$(check_latest_tx_history_transfer "$contract_addr" "${ADDRESS[a]}" "${VK[a]}" \
        "${ADDRESS[a]}" "${ADDRESS[a]}" "$receiver_addr" 400000 "$timestamp" "$block_height")"
    assert_eq "$tx_id1" "$tx_id2"

    # Check that "a" has fewer funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 600000

    # Test that send callback failure also denies the transfer
    log 'sending funds from "a" to the Receiver, with a "Fail" message to the Receiver'
    receiver_msg='{"fail":{}}'
    receiver_msg="$(base64 <<<"$receiver_msg")"
    send_message='{"send":{"recipient":"'"$receiver_addr"'","amount":"400000","msg":"'$receiver_msg'"}}'
    tx_hash="$(compute_execute "$contract_addr" "$send_message" ${FROM[a]} --gas 300000)"
    # Notice the `!` before the command - it is EXPECTED to fail.
    ! send_response="$(wait_for_compute_tx "$tx_hash" 'waiting for send from "a" to the Receiver to process')"
    assert_eq "$(get_generic_err "$send_response")" 'intentional failure' # This comes from the receiver contract

    # Check that "a" does not have fewer funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 600000 # This is the same balance as before

    log 'a failure in the callback caused the transfer to roll back, as expected'

    # redeem both accounts
    redeem "$contract_addr" 'a' 600000
    redeem_receiver "$receiver_addr" "$contract_addr" "${ADDRESS[a]}" 400000
}

function set_minters() {
    #    set -e
    local minters

    if (( $# == 0 )); then
        minters='[]'
    else
        minters='["'

        for minter in "${@:1:$(($# - 1))}"; do
            minters="${minters}${minter}"'","'
        done

        minters="${minters}${*: -1}"'"]'
    fi

    log "$minters"

    local set_minters_message='{"set_minters":{"minters":'"$minters"'}}'
    local tx_hash
    local response
    tx_hash="$(compute_execute "$contract_addr" "$set_minters_message" ${FROM[a]} --gas 150000)"
    response="$(data_of wait_for_compute_tx "$tx_hash" "waiting for minter set to update")"
    assert_eq "$response" "$(pad_space '{"set_minters":{"status":"success"}}')"
    log "set the minters to these addresses: $*"
}

# This test also tests TokenInfo
function test_burn() {
    set -e
    local contract_addr="$1"

    log_test_header

    local token_info_response
    local burn_response
    local tx_hash

    set_minters "${ADDRESS[b]}"

    # minting from the wrong account should fail
    set +e; tx_hash="$(mint "$contract_addr" 'a' "${ADDRESS[a]}" 1000000)"
    local _res="$?"; set -e;
    if (( _res != 0 )); then
        assert_eq "$(get_generic_err "$(secretcli query compute tx "$tx_hash")")" 'Minting is allowed to minter accounts only'
        log 'minting from the wrong account failed as expected'
    else
        log 'minting was allowed from a non-minter address!'
        return 1
    fi

    # Mint to a using b
    local native_tx
    local timestamp
    local block_height
    tx_hash="$(mint "$contract_addr" 'b' "${ADDRESS[a]}" 1000000)"
    native_tx="$(secretcli q tx "$tx_hash")"
    timestamp="$(unix_time_of_tx "$native_tx")"
    block_height="$(jq -r '.height' <<<"$native_tx")"
    check_latest_tx_history_mint "$contract_addr" "${ADDRESS[a]}" "${VK[a]}" \
        "${ADDRESS[b]}" "${ADDRESS[a]}" 1000000 "$timestamp" "$block_height"

    # Check total supply
    token_info_response="$(get_token_info "$contract_addr")"
    log 'token info response was' "$token_info_response"
    assert_eq "$(jq -r '.token_info.total_supply' <<<"$token_info_response")" 1000000

    # Try to over-burn
    local burn_message='{"burn":{"amount":"10000000"}}' # 110%
    local burn_response
    tx_hash="$(compute_execute "$contract_addr" "$burn_message" ${FROM[a]} --gas 150000)"
    ! burn_response="$(wait_for_compute_tx "$tx_hash" 'waiting for burn for "a" to process')"
    assert_eq "$(get_generic_err "$burn_response")" 'insufficient funds to burn: balance=1000000, required=10000000'

    # Check "a" balance - should not have changes
    assert_eq "$(get_balance "$contract_addr" 'a')" 1000000

    # Check total supply
    token_info_response="$(get_token_info "$contract_addr")"
    log 'token info response was' "$token_info_response"
    assert_eq "$(jq -r '.token_info.total_supply' <<<"$token_info_response")" 1000000

    # Try to burn
    quiet burn "$contract_addr" 'a' 100000 # 10%

    # Check "a" balance
    assert_eq "$(get_balance "$contract_addr" 'a')" 900000

    # Check total supply
    token_info_response="$(get_token_info "$contract_addr")"
    log 'token info response was' "$token_info_response"
    assert_eq "$(jq -r '.token_info.total_supply' <<<"$token_info_response")" 900000

    # Burn the rest of the balance
    tx_hash="$(burn "$contract_addr" 'a' 900000)"
    log "the tx_hash is $tx_hash"
    native_tx="$(secretcli q tx "$tx_hash")"
    timestamp="$(unix_time_of_tx "$native_tx")"
    block_height="$(jq -r '.height' <<<"$native_tx")"
    check_latest_tx_history_burn "$contract_addr" "${ADDRESS[a]}" "${VK[a]}" \
        "${ADDRESS[a]}" "${ADDRESS[a]}" 900000 "$timestamp" "$block_height"

    token_info_response="$(get_token_info "$contract_addr")"
    log 'token info response was' "$token_info_response"
    assert_eq "$(jq -r '.token_info.total_supply' <<<"$token_info_response")" 0
}

function test_transfer_from() {
    set -e
    local contract_addr="$1"

    log_test_header

    local tx_hash

    # Check "a", "b", and "c" don't have any funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 0
    assert_eq "$(get_balance "$contract_addr" 'b')" 0
    assert_eq "$(get_balance "$contract_addr" 'c')" 0

    # Check that the allowance given to "b" by "a" is zero
    assert_eq "$(get_allowance "$contract_addr" 'a' 'b')" 0

    # Deposit to "a"
    quiet deposit "$contract_addr" 'a' 1000000

    # Make "a" give allowance to "b"
    assert_eq "$(increase_allowance "$contract_addr" 'a' 'b' 1000000)" 1000000
    assert_eq "$(get_allowance "$contract_addr" 'a' 'b')" 1000000

    # Try to transfer from "a", using "b" more than "a" has allowed
    log 'transferring funds from "a" to "c" using "b", but more than "a" has allowed'
    local transfer_message='{"transfer_from":{"owner":"'"${ADDRESS[a]}"'","recipient":"'"${ADDRESS[c]}"'","amount":"1000001"}}'
    local transfer_response
    tx_hash="$(compute_execute "$contract_addr" "$transfer_message" ${FROM[b]} --gas 150000)"
    # Notice the `!` before the command - it is EXPECTED to fail.
    ! transfer_response="$(wait_for_compute_tx "$tx_hash" 'waiting for transfer from "a" to "c" by "b" to process')"
    log "trying to overdraft from \"a\" to transfer to \"c\" using \"b\" was rejected"
    assert_eq "$(get_generic_err "$transfer_response")" "insufficient allowance: allowance=1000000, required=1000001"

    # Check both "a", "b", and "c", that their last transaction is not for 1000001 uscrt
    local txs
    for key in a b c; do
        log "querying the transfer history of \"$key\""
        txs="$(get_transfer_history "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" 1 0)"
        silent jq -e 'length <= 1' <<<"$txs" # just make sure we're not getting a weird response
        if silent jq -e 'length == 1' <<<"$txs"; then
            assert_ne "$(jq -r '.[0].coins.amount' <<<"$txs")" 1000001
        fi
    done

    # Transfer from "a" to "c" using "b"
    log 'transferring funds from "a" to "c" using "b"'
    local transfer_message='{"transfer_from":{"owner":"'"${ADDRESS[a]}"'","recipient":"'"${ADDRESS[c]}"'","amount":"400000"}}'
    local transfer_response
    tx_hash="$(compute_execute "$contract_addr" "$transfer_message" ${FROM[b]} --gas 250000)"
    transfer_response="$(data_of wait_for_compute_tx "$tx_hash" 'waiting for transfer from "a" to "c" by "b" to process')"
    assert_eq "$transfer_response" "$(pad_space '{"transfer_from":{"status":"success"}}')"

    local native_tx
    native_tx="$(secretcli q tx "$tx_hash")"
    local timestamp
    timestamp="$(unix_time_of_tx "$native_tx")"
    local block_height
    block_height="$(jq -r '.height' <<<"$native_tx")"

    # Check for both "a", "b", and "c" that they recorded the transfer
    local -A tx_ids
    local tx_id
    for key in a b c; do
        log "querying the transfer history of \"$key\""
        tx_ids[$key]="$(
            check_latest_transfer_history "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" \
                "${ADDRESS[b]}" "${ADDRESS[a]}" "${ADDRESS[c]}" 400000 "$timestamp" "$block_height"
        )"
        tx_id="$(
            check_latest_tx_history_transfer "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" \
                "${ADDRESS[b]}" "${ADDRESS[a]}" "${ADDRESS[c]}" 400000 "$timestamp" "$block_height"
        )"
        assert_eq "$tx_id" "${tx_ids[$key]}"
    done

    assert_eq "${tx_ids[a]}" "${tx_ids[b]}"
    assert_eq "${tx_ids[b]}" "${tx_ids[c]}"
    log 'The transfer was recorded correctly in the transaction history'

    # Check that "a" has fewer funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 600000

    # Check that "b" has the same funds still, but less allowance
    assert_eq "$(get_balance "$contract_addr" 'b')" 0
    assert_eq "$(get_allowance "$contract_addr" 'a' 'b')" 600000

    # Check that "c" has the funds that "b" deposited from "a"
    assert_eq "$(get_balance "$contract_addr" 'c')" 400000

    # Redeem both accounts
    redeem "$contract_addr" a 600000
    redeem "$contract_addr" c 400000
    # Reset allowance
    assert_eq "$(decrease_allowance "$contract_addr" 'a' 'b' 600000)" 0
    assert_eq "$(get_allowance "$contract_addr" 'a' 'b')" 0
    # Send the funds back
    quiet secretcli tx send c "${ADDRESS[a]}" 400000uscrt -y -b block
}

function test_send_from() {
    set -e
    local contract_addr="$1"

    log_test_header

    local receiver_addr
    receiver_addr="$(create_receiver_contract)"
    # receiver_addr='secret17k8qt6aqd7eee3fawmtvy4vu6teqx8d7mdm49x'
    register_receiver "$receiver_addr" "$contract_addr"

    local tx_hash

    # Check "a" and "b" don't have any funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 0
    assert_eq "$(get_balance "$contract_addr" 'b')" 0
    assert_eq "$(get_balance "$contract_addr" 'c')" 0

    # Check that the allowance given to "b" by "a" is zero
    assert_eq "$(get_allowance "$contract_addr" 'a' 'b')" 0

    # Deposit to "a"
    quiet deposit "$contract_addr" 'a' 1000000

    # Make "a" give allowance to "b"
    assert_eq "$(increase_allowance "$contract_addr" 'a' 'b' 1000000)" 1000000
    assert_eq "$(get_allowance "$contract_addr" 'a' 'b')" 1000000

    # TTry to send from "a", using "b" more than "a" has allowed
    log 'sending funds from "a" to "c" using "b", but more than "a" has allowed'
    local send_message='{"send_from":{"owner":"'"${ADDRESS[a]}"'","recipient":"'"${ADDRESS[c]}"'","amount":"1000001"}}'
    local send_response
    tx_hash="$(compute_execute "$contract_addr" "$send_message" ${FROM[b]} --gas 150000)"
    # Notice the `!` before the command - it is EXPECTED to fail.
    ! send_response="$(wait_for_compute_tx "$tx_hash" 'waiting for send from "a" to "c" by "b" to process')"
    log "trying to overdraft from \"a\" to send to \"c\" using \"b\" was rejected"
    assert_eq "$(get_generic_err "$send_response")" "insufficient allowance: allowance=1000000, required=1000001"

    # Check both a and b, that their last transaction is not for 1000001 uscrt
    local txs
    for key in a b c; do
        log "querying the transfer history of \"$key\""
        txs="$(get_transfer_history "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" 1 0)"
        silent jq -e 'length <= 1' <<<"$txs" # just make sure we're not getting a weird response
        if silent jq -e 'length == 1' <<<"$txs"; then
            assert_ne "$(jq -r '.[0].coins.amount' <<<"$txs")" 1000001
        fi
    done

    # Query receiver state before Send
    local receiver_state
    local receiver_state_query='{"get_count":{}}'
    receiver_state="$(compute_query "$receiver_addr" "$receiver_state_query")"
    local original_count
    original_count="$(jq -r '.count' <<<"$receiver_state")"

    # Send from "a", using "b", to the receiver with message to the Receiver
    log 'sending funds from "a", using "b", to the Receiver, with message to the Receiver'
    local receiver_msg='{"increment":{}}'
    receiver_msg="$(base64 <<<"$receiver_msg")"
    local send_message='{"send_from":{"owner":"'"${ADDRESS[a]}"'","recipient":"'"$receiver_addr"'","amount":"400000","msg":"'$receiver_msg'"}}'
    local send_response
    tx_hash="$(compute_execute "$contract_addr" "$send_message" ${FROM[b]} --gas 302000)"
    send_response="$(wait_for_compute_tx "$tx_hash" 'waiting for send from "a" to the Receiver to process')"
    assert_eq \
        "$(jq -r '.output_log[0].attributes[] | select(.key == "count") | .value' <<<"$send_response")" \
        "$((original_count + 1))"
    log 'received send response'

    local native_tx
    native_tx="$(secretcli q tx "$tx_hash")"
    local timestamp
    timestamp="$(unix_time_of_tx "$native_tx")"
    local block_height
    block_height="$(jq -r '.height' <<<"$native_tx")"

    # Check that the receiver got the message
    log 'checking whether state was updated in the receiver'
    receiver_state_query='{"get_count":{}}'
    receiver_state="$(compute_query "$receiver_addr" "$receiver_state_query")"
    local new_count
    new_count="$(jq -r '.count' <<<"$receiver_state")"
    assert_eq "$((original_count + 1))" "$new_count"
    log 'receiver contract received the message'

    # Check that "a" recorded the transfer
    local -A tx_ids
    local tx_id
    for key in a b; do
        log "querying the transfer history of \"$key\""
        tx_ids[$key]="$(
            check_latest_transfer_history "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" \
                "${ADDRESS[b]}" "${ADDRESS[a]}" "$receiver_addr" 400000 "$timestamp" "$block_height"
        )"
        tx_id="$(
            check_latest_tx_history_transfer "$contract_addr" "${ADDRESS[$key]}" "${VK[$key]}" \
                "${ADDRESS[b]}" "${ADDRESS[a]}" "$receiver_addr" 400000 "$timestamp" "$block_height"
        )"
        assert_eq "$tx_id" "${tx_ids[$key]}"
    done

    assert_eq "${tx_ids[a]}" "${tx_ids[b]}"
    log 'The transfer was recorded correctly in the transaction history'

    # Check that "a" has fewer funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 600000

    # Check that "b" has the same funds still, but less allowance
    assert_eq "$(get_balance "$contract_addr" 'b')" 0
    assert_eq "$(get_allowance "$contract_addr" 'a' 'b')" 600000

    # Test that send callback failure also denies the transfer
    log 'sending funds from "a", using "b", to the Receiver, with a "Fail" message to the Receiver'
    receiver_msg='{"fail":{}}'
    receiver_msg="$(base64 <<<"$receiver_msg")"
    send_message='{"send_from":{"owner":"'"${ADDRESS[a]}"'", "recipient":"'"$receiver_addr"'","amount":"400000","msg":"'$receiver_msg'"}}'
    tx_hash="$(compute_execute "$contract_addr" "$send_message" ${FROM[b]} --gas 300000)"
    # Notice the `!` before the command - it is EXPECTED to fail.
    ! send_response="$(wait_for_compute_tx "$tx_hash" 'waiting for send from "a" to the Receiver to process')"
    assert_eq "$(get_generic_err "$send_response")" 'intentional failure' # This comes from the receiver contract

    # Check that "a" does not have fewer funds
    assert_eq "$(get_balance "$contract_addr" 'a')" 600000 # This is the same balance as before

    log 'a failure in the callback caused the transfer to roll back, as expected'

    # redeem both accounts
    redeem "$contract_addr" 'a' 600000
    redeem_receiver "$receiver_addr" "$contract_addr" "${ADDRESS[a]}" 400000
    # Reset allowance
    assert_eq "$(decrease_allowance "$contract_addr" 'a' 'b' 600000)" 0
    assert_eq "$(get_allowance "$contract_addr" 'a' 'b')" 0
}

function main() {
    log '              <####> Starting integration tests <####>'
    log "secretcli version in the docker image is: $(secretcli version)"

    local prng_seed
    prng_seed="$(base64 <<<'enigma-rocks')"
    local init_msg
    init_msg='{"name":"secret-secret","admin":"'"${ADDRESS[a]}"'","symbol":"SSCRT","decimals":6,"initial_balances":[],"prng_seed":"'"$prng_seed"'","config":{"public_total_supply":true,"enable_deposit":true,"enable_redeem":true,"enable_mint":true,"enable_burn":true}}'
    contract_addr="$(create_contract '.' "$init_msg")"

    # To make testing faster, check the logs and try to reuse the deployed contract and VKs from previous runs.
    # Remember to comment out the contract deployment and `test_viewing_key` if you do.
#    local contract_addr='secret18vd8fpwxzck93qlwghaj6arh4p7c5n8978vsyg'
#    VK[a]='<KEY>
#    VK[b]='api_key_YoQlmqnOkkEoh81XzFkiZ3z7+ZAJh9kyFXvtaMBhiFU='
#    VK[c]='api_key_/<KEY>
#    VK[d]='api_key_WQYkuGOco/mSHgtKWG0f7b2UcrSG3s1fIqm1X/wIGDo='

    log "contract address: $contract_addr"

    # This first test also sets the `VK[*]` global variables that are used in the other tests
    test_viewing_key "$contract_addr"
    test_deposit "$contract_addr"
    test_transfer "$contract_addr"
    test_send "$contract_addr"
    test_burn "$contract_addr"
    test_transfer_from "$contract_addr"
    test_send_from "$contract_addr"

    log 'Tests completed successfully'

    # If everything else worked, return successful status
    return 0
}

main "$@"


<reponame>winsnyder/reactjs_source_fe<filename>build_image.sh
TAG=$(date '+%Y%d%m.%H%M%S')

ImageName="frontend_base"
echo "Building image $ImageName:$TAG"
docker build . -t $ImageName:$TAG
docker tag $ImageName:$TAG $ImageName:latest


#!/bin/bash

#Expected output: f41a60f7-de4a-4b17-9f54-387e52d60b65	3086	186	251	+	Escherichia_coli_chromosome:2400000-2410000	10000	6826	6891	63	66	255

cd `dirname "${BASH_SOURCE[0]}"`

if [ -d index ]; then
    rm -r index
fi

mkdir index
../bwa/bwa index -p index/example_ref example_ref.fa
uncalled index -x index/example_ref -i example_ref.fa
uncalled map -x index/example_ref -i fast5_filename.txt


#! /bin/bash

# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.

set -eu
shopt -s lastpipe

xfakeroot() {
    LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}/\$LIB/libfakeroot:/usr/\$LIB/libfakeroot" \
    LD_PRELOAD="${LD_PRELOAD:+LD_PRELOAD:}libfakeroot-sysv.so" \
    "$@"
}

mount_cgroup() {
    local -r line="$1"

    local ctrl=""
    local path=""
    local mtab=""
    local root=""
    local mount=""

    cut -d: -f2,3 <<< "${line}" | IFS=':' read -r ctrl path
    if [ -n "${ctrl}" ]; then
        mtab=$(grep -m1 "\- cgroup cgroup [^ ]*${ctrl}" /proc/self/mountinfo || true)
    else
        mtab=$(grep -m1 "\- cgroup2 cgroup" /proc/self/mountinfo || true)
    fi
    if [ -z "${mtab}" ]; then
        return
    fi
    cut -d' ' -f4,5 <<< "${mtab}" | IFS=' ' read -r root mount

    mkdir -p "${ENROOT_ROOTFS}/${mount:1}"
    xfakeroot mount -n --bind "${mount}/${path#${root}}" "${ENROOT_ROOTFS}/${mount:1}"
    xfakeroot mount -n -o bind,remount,nosuid,noexec,nodev,ro "${ENROOT_ROOTFS}/${mount:1}"
}

while read line; do
    mount_cgroup "${line}"
done < /proc/self/cgroup

xfakeroot mount -n -o bind,remount,nosuid,noexec,nodev,ro "${ENROOT_ROOTFS}/sys/fs/cgroup"


#!bin/bash

#
# This script convert the ontologies that were used for the experiments that have been published in the paper.
#

module load compilers-extra
module load oracle-java/1.8.0.51
module load groovy
module load apache-groovy

ontologies=("GO_36.owl"
			"GO-PLUS_1.owl")
reasoners=("ELK"
		   "SYNTACTIC_REASONER")
transitive=("true"
		   "false")

idOntologies=("go"
			 "goplus")
idReasoners=("elk"
			 "sr")
idTransitive=("True"
			  "False")

for ont in ${!ontologies[*]}
do
	for r in ${!reasoners[*]}
	do
		for tr in ${!transitive[*]}
		do
 			nohup java -jar Onto2Graph.jar \
 			-ont ${ontologies[$ont]} \
 			-out outputs/${idOntologies[$ont]}_${idReasoners[$r]}_rdfxml_eqFalse_t${idTransitive[$tr]}.rdfxml \
 			-r ${reasoners[$r]} \
 			-f RDFXML \
 			-eq false \
 			-t ${transitive[$tr]} \
 			-nt 4 > outputs/${idOntologies[$ont]}_${idReasoners[$r]}_rdfxml_eqFalse_t${idTransitive[$tr]}.output &

 			nohup java -jar Onto2Graph.jar \
 			-ont ${ontologies[$ont]} \
 			-out outputs/${idOntologies[$ont]}_${idReasoners[$r]}_rdfxml_eqFalse_property_t${idTransitive[$tr]}.rdfxml \
 			-r ${reasoners[$r]} \
 			-f RDFXML \
 			-eq false \
 			-op [\"part of\"] \
 			-t ${transitive[$tr]} \
 			-nt 4 > outputs/${idOntologies[$ont]}_${idReasoners[$r]}_rdfxml_eqFalse_property_t${idTransitive[$tr]}.output &

 			nohup java -jar Onto2Graph.jar \
 			-ont ${ontologies[$ont]} \
 			-out outputs/${idOntologies[$ont]}_${idReasoners[$r]}_rdfxml_eqFalse_properties_t${idTransitive[$tr]}.rdfxml \
 			-r ${reasoners[$r]} \
 			-f RDFXML \
 			-eq false \
 			-op [\"part of\",\"regulates\"] \
 			-t ${transitive[$tr]} \
 			-nt 4 > outputs/${idOntologies[$ont]}_${idReasoners[$r]}_eqFalse_properties_t${idTransitive[$tr]}.output &
 		done
 	done
done


#! /bin/bash

# Train model and Test model

# Additional experiments [Increasing the number of epoch for GRU and CNN cell]
python ../sentence_classification.py --cell_type="GRU" --n_layer=3 --n_cell=32 --n_epoch=600 --dropout_keep_prob=0.7 --exp_name="add_exp01_3layer_600epoch"
python ../sentence_classification.py --cell_type="CNN" --n_epoch=600 --n_layer=1 --dropout_keep_prob=0.7 --exp_name="add_exp01_3layer_600epoch";

echo "Additional experiment \"Increasing the number of epoch for GRU and CNN cell\" has been complected."


#!/bin/bash
npm publish ./dist/rucken/todo-nestjs
read -p "Press any key to continue... " -n1 -s


<filename>EMR/usr/share/nginx/html/library/adldap/adLDAP_sync.sh
#!/bin/bash
#
# This executes the adLDAP_sync.php script
#
# Run this script on a regular basis to keep the OpenEMR Users table
# in sync with the your Active Directory users

php adLDAP_sync.php


<reponame>leboisdesbruyere/esp-idf<gh_stars>1-10
#!/usr/bin/env bash

function help() {
  echo "Usage: bash build_espcoredump.sh [OUTPUT_DIR]"
}

if [ -z "$1" ]; then
  help
  exit 1
else
  output_dir=$1
fi

SUPPORTED_TARGETS=("esp32" "esp32s2" "esp32c3")
for chip in "${SUPPORTED_TARGETS[@]}"; do
  {
    echo "--------------------------"
    echo "building $chip binaries..."
    echo "--------------------------"
    idf.py fullclean && rm -f sdkconfig
    idf.py set-target $chip
    idf.py build
    cp ./build/test_core_dump.elf "${output_dir}/${chip}.elf"
  }
done


flutter test --coverage --machine > machine.jsonl
flutter pub run remove_from_coverage -f coverage/lcov.info -r '.freezed.dart$' -r '.g.dart$' -r '^lib/src/generated' -r 'lib/src/messages.dart'
genhtml coverage/lcov.info -o coverage --no-function-coverage -s -p `pwd`
open ./coverage/index.html


<reponame>Htet-Phyo-Lin/autoTask
#!/bin/bash

sudo /etc/init.d/windscribe-cli start
sudo windscribe disconnect
sudo windscribe connect
sudo windscribe account


# 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.
################################################################################

#!/bin/bash

ROOT_DIR="$TEST_SRCDIR/tink"
CC_MAC_CLI="$ROOT_DIR/tools/testing/cc/mac_cli_cc"
GO_MAC_CLI="$ROOT_DIR/tools/testing/go/mac_cli_go"
JAVA_MAC_CLI="$ROOT_DIR/tools/testing/mac_cli_java"
TEST_UTIL="$ROOT_DIR/tools/testing/cross_language/test_util.sh"

source $TEST_UTIL || exit 1

#############################################################################
### Helpers for MAC-tests.

# Basic tests of MAC-implementations.
mac_basic_test() {
  local test_name="mac-basic-test"
  local compute_mac_clis=$1
  local verify_mac_clis=$2
  local key_templates=$3

  echo "############ starting test $test_name for the following templates:"
  echo $key_templates
    for key_template in ${key_templates[*]}
    do
      echo "## TEST for key template $key_template"
      echo $compute_mac_clis
      for compute_mac_cli in ${compute_mac_clis[*]}
      do
        local compute_mac_cli_name=`get_file_name $compute_mac_cli`
        echo "## COMPUTING MAC using $compute_mac_cli_name"
        local test_instance="${test_name}_${key_template}"

        generate_symmetric_key "${test_instance}_MAC_${compute_mac_cli_name}" $key_template
        generate_plaintext $test_instance

        local mac_file="$TEST_TMPDIR/${test_instance}_MAC_${compute_mac_cli_name}_mac.bin"

        $compute_mac_cli $symmetric_key_file "compute" $plaintext_file\
            $mac_file || exit 1
        assert_files_different $plaintext_file $mac_file

        for verify_mac_cli in ${verify_mac_clis[*]}
        do
          local verify_mac_cli_name=`get_file_name $verify_mac_cli`
          local result_file="$TEST_TMPDIR/${test_instance}_MAC_${compute_mac_cli_name}_VERIFY_${verify_mac_cli_name}_verification.txt"

          echo "## VERIFYING using $verify_mac_cli_name"

          $verify_mac_cli $symmetric_key_file "verify" $plaintext_file\
              $mac_file $result_file || exit 1
          assert_file_equals "valid" $result_file

        done
      done
    done
}

#############################################################################
##### Run the actual tests.

KEY_TEMPLATES=(HMAC_SHA256_128BITTAG HMAC_SHA256_256BITTAG HMAC_SHA512_256BITTAG HMAC_SHA512_512BITTAG)
MAC_CLIS=($CC_MAC_CLI $JAVA_MAC_CLI $GO_MAC_CLI)
VERIFY_CLIS=($CC_MAC_CLI $JAVA_MAC_CLI $GO_MAC_CLI)
mac_basic_test "${MAC_CLIS[*]}" "${VERIFY_CLIS[*]}" \
    "${KEY_TEMPLATES[*]}"


<filename>macos/set-defaults.sh<gh_stars>1-10
# Sets reasonable macOS defaults.
#
# Or, in other words, set shit how I like in macOS.
#
# The original idea (and a couple settings) were grabbed from:
#   https://github.com/mathiasbynens/dotfiles/blob/master/.macos
#
# Run ./set-defaults.sh and you'll be good to go.

# Disable press-and-hold for keys in favor of key repeat.
defaults write -g ApplePressAndHoldEnabled -bool false

# Show the ~/Library folder.
chflags nohidden ~/Library

# Show the /Volumes folder
sudo chflags nohidden /Volumes

# Set a really fast key repeat.
defaults write NSGlobalDomain KeyRepeat -int 1

#customize touchbar to remove siri and add lock screen
defaults write com.apple.controlstrip MiniCustomized -array "com.apple.system.brightness" "com.apple.system.volume" "com.apple.system.mute" "com.apple.system.screen-lock"

# Set the Finder prefs for showing a few different volumes on the Desktop.
defaults write com.apple.finder AppleShowAllFiles YES
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
# Always open everything in Finder's list view. This is important.
defaults write com.apple.finder FXPreferredViewStyle Nlsv
# Finder: allow quitting via ⌘ + Q; doing so will also hide desktop icons
defaults write com.apple.finder QuitMenuItem -bool true
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
defaults write com.apple.finder ShowStatusBar -bool true
defaults write com.apple.finder ShowPathbar -bool true
# Avoid creating .DS_Store files on network or USB volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

defaults write com.apple.screensaver askForPassword -int 5

defaults write com.apple.menuextra.battery ShowPercent -bool true

# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false

# Automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true

# Reveal IP address, hostname, OS version, etc. when clicking the clock
# in the login window
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName

# Disable smart quotes as they’re annoying when typing code
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false

# Disable smart dashes as they’re annoying when typing code
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false

defaults write com.apple.dock autohide -int 1
defaults write com.apple.dock magnification -int 0
defaults write com.apple.dock largesize -int 100

defaults write com.apple.AppleMultitouchTrackpad Clicking -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -int 1

# Trackpad: enable tap to click for this user and for the login screen
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1

# Trackpad: map bottom right corner to right-click
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 2
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true
defaults -currentHost write NSGlobalDomain com.apple.trackpad.trackpadCornerClickBehavior -int 1
defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool true

# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 64

defaults write NSGlobalDomain AppleLanguages -array "en-DE" "de-DE"
defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
defaults write NSGlobalDomain AppleMetricUnits -bool true

# Set up Safari for development.
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

# iterm load external settings
defaults write com.googlecode.iterm2 PrefsCustomFolder -string "/Users/kong/.dotfiles/iterm/"
defaults write com.googlecode.iterm2 LoadPrefsFromCustomFolder -bool true


# ----------------------------------------------------------------------------
#
# Package       : PyOpenGL-accelerate-3.1.0
# Version       : 3.1.0
# Tested on     : rhel_7.3 (python27)
# Script License: Apache License
# Maintainer    : <NAME> <<EMAIL>>
#
# Disclaimer: This script has been tested in non-root mode on given
# ==========  platform using the mentioned version of the package.
#             It may not work as expected with newer versions of the
#             package and/or distribution. In such case, please
#             contact "Maintainer" of this script.
#
# ----------------------------------------------------------------------------
#!/bin/bash

# Update source and Install dependencies
sudo yum update -y
sudo yum install -y wget tar python python-devel python-setuptools gcc numpy
wget https://pypi.python.org/packages/d9/74/293aa8794f2f236186d19e61c5548160bfe159c996ba01ed9144c89ee8ee/PyOpenGL-accelerate-3.1.0.tar.gz#md5=489338a4818fa63ea54ff3de1b48995c
tar -xvf PyOpenGL-accelerate-3.1.0.tar.gz
cd PyOpenGL-accelerate-3.1.0

# Build and Install
python setup.py build
sudo python setup.py install
python setup.py test


sudo docker stop cyber-event-collector
sudo docker rm cyber-event-collector


#!/bin/sh

set -e

apt-get update

DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    gcc libxml2-dev libpq-dev libfcgi-dev \
    autoconf make flex libfl-dev \
    postgresql-12 postgresql-client postgis postgresql-12-postgis-3 postgresql-12-postgis-3-scripts \
    wget ca-certificates patch valgrind

cd "${WORK_DIR}"
./autogen.sh
CFLAGS="-Werror" ./configure
make
make install

cp /etc/postgresql/12/main/pg_hba.conf /etc/postgresql/12/main/pg_hba.conf.bak
echo "local all postgres trust" |  cat - /etc/postgresql/12/main/pg_hba.conf.bak > /etc/postgresql/12/main/pg_hba.conf
echo "host all all 127.0.0.1/32 trust" |  cat - /etc/postgresql/12/main/pg_hba.conf.bak > /etc/postgresql/12/main/pg_hba.conf
/etc/init.d/postgresql start

rm -f /etc/tinyows.xml
make install-demo
cp -f demo/tinyows_no_checkschema.xml /etc/tinyows.xml
make check

# wget https://github.com/MapServer/tinyows/commit/633ca487113d032e261a4a5c8b5f3b7850580f4f.patch
# patch -p1 -R < 633ca487113d032e261a4a5c8b5f3b7850580f4f.patch

# rm -f /etc/tinyows.xml
# make install-test100

# rm -f /etc/tinyows.xml
# make install-test110


#!/bin/bash

if [ "$1" = "" ]; then
  echo "Usage: $0 version"
  echo "Update the choco package to a given version"
  echo "Example: $0 1.7.4"
  exit 1
fi

if [[ "${OSTYPE}" != "darwin"* && "${OSTYPE}" != "linux-gnu"* ]]; then
  echo "This version support Mac and Windows Subsystem for Linux"
  exit 2
fi

version=$1

url="https://storage.googleapis.com/golang/go${version}.windows-386.zip"
url64="https://storage.googleapis.com/golang/go${version}.windows-amd64.zip"

checksum=$(curl "${url}.sha256")
checksum64=$(curl "${url64}.sha256")

sed -i.bak "s/<version>.*<\/version>/<version>${version}<\/version>/" golang.nuspec

sed -i.bak "s!^\$url = '.*'!\$url = '${url}'!" tools/chocolateyinstall.ps1
sed -i.bak "s/^\$checksum = '.*'/\$checksum = '${checksum}'/" tools/chocolateyinstall.ps1
sed -i.bak "s!^\$url64 = '.*'!\$url64 = '${url64}'!" tools/chocolateyinstall.ps1
sed -i.bak "s/^\$checksum64 = '.*'/\$checksum64 = '${checksum64}'/" tools/chocolateyinstall.ps1


<gh_stars>0
is_interactive_shell || return

## Amazon AWS CLI
complete -C aws_completer aws


<filename>ipsc_validation/work/94/f6bb9d1c37dde724dc9a1a54d62808/.command.sh
#!/bin/bash -ue
SFA_virtscreen.py network.sif expressions.csv EpiSC samples.txt fvs.txt fvs_init.txt 0.9


<filename>local_registry.sh
#!/bin/bash

sudo mkdir -p /private/registry/data
sudo mkdir -p /private/registry/auth
sudo mkdir -p /private/registry/cert
sudo chown -R $(whoami) /private/registry/

sudo docker run --entrypoint htpasswd registry:2 -Bbn admin admin > /private/registry/auth/htpasswd

sudo openssl req -newkey rsa:4096 -nodes -sha256 -keyout /private/registry/cert/domain.key -x509 -days 365 -subj '/emailAddress=<EMAIL>/C=IN/ST=IN/L=Bangalore/O=Shree/OU=IT/CN=internal-registry.com' -out /private/registry/cert/domain.crt

sudo docker run -p 5000:5000 --restart=always  -v /private/registry/data:/var/lib/registry -v /private/registry/auth:/auth -v /private/registry/cert:/cert -e REGISTRY_AUTH=htpasswd -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd -e REGISTRY_AUTH_HTPASSWD_REALM="Registry Realm" -e REGISTRY_HTTP_TLS_CERTIFICATE=/cert/domain.crt -e  REGISTRY_HTTP_TLS_KEY=/cert/domain.key registry:2


<reponame>tracysmith/RGAPepPipe<gh_stars>1-10
#!/bin/bash

java -Xmx2g -jar /opt/PepPrograms/RGAPipeline/GenomeAnalysisTK.jar -T RealignerTargetCreator -R $1 "${@:3}" -o $2.intervals

java -Xmx4g -jar /opt/PepPrograms/RGAPipeline/GenomeAnalysisTK.jar -T IndelRealigner -R $1 "${@:3}" -targetIntervals $2.intervals -nWayOut .patrealn.bam


#!/bin/bash
xhost +local:docker
nvidia-docker run -d -e DISPLAY=$DISPLAY --device=/dev/video0:/dev/video0 -v /tmp/.X11-unix/X0:/tmp/.X11-unix/X0 -v /home/ubuntu/data/:/data -it garyfeng/docker-openpose:latest  \
./build/examples/openpose/openpose.bin --camera 0 --write_keypoint_json /data/keypoint_json > ./docker_start.pid

# Helpful commands
# ./build/examples/openpose/openpose.bin --video /data/output/gangnam.mp4 --write_images /data/output/images/rendered/ --write_keypoint_json /data/output/json --process_real_time --disable_blending
#./build/examples/openpose/openpose.bin --video /data/otherway.MOV --write_images /data/fastai/cached_images_folder/  --process_real_time --output_resolution 400x400
#./build/examples/openpose/openpose.bin --camera 0 --write_images /data/fastai/cached_images_folder/
# 377.561, 596.708
# 318.947, 148.639


<reponame>SpeedVan/supply-chain-finance-on-fabric

sh gyl_orderer/sbin/createCert.sh
sh gyl_core_org1/sbin/createCert.sh
sh gyl_f_org1/sbin/createCert.sh
sh gyl_s_org1/sbin/createCert.sh
sh gyl_s_org2/sbin/createCert.sh

sh gyl_orderer/sbin/createBlock.sh


#!/usr/bin/env bash
#
# This file is part of the KubeVirt project
#
# 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.
#
# Copyright 2017 Red Hat, Inc.
#

# This logic moved into the Makefile.
# We're leaving this file around for people who still reference this
# specific script in their development workflow.

set -e

DOCKER_TAG=${DOCKER_TAG:-devel}
DOCKER_TAG_ALT=${DOCKER_TAG_ALT:-devel_alt}

source hack/common.sh
source cluster-up/cluster/$KUBEVIRT_PROVIDER/provider.sh
source hack/config.sh

echo "Building ..."

# Build everyting and publish it
${KUBEVIRT_PATH}hack/dockerized "BUILD_ARCH=${BUILD_ARCH} DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./hack/build-func-tests.sh"
${KUBEVIRT_PATH}hack/dockerized "BUILD_ARCH=${BUILD_ARCH} DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} IMAGE_PREFIX=${IMAGE_PREFIX} IMAGE_PREFIX_ALT=${IMAGE_PREFIX_ALT} ./hack/bazel-push-images.sh"
${KUBEVIRT_PATH}hack/dockerized "BUILD_ARCH=${BUILD_ARCH} DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY} VERBOSITY=${VERBOSITY} IMAGE_PREFIX=${IMAGE_PREFIX}  IMAGE_PREFIX_ALT=${IMAGE_PREFIX_ALT} feature_gates=${FEATURE_GATES} KUBEVIRT_ONLY_USE_TAGS=${KUBEVIRT_ONLY_USE_TAGS} ./hack/build-manifests.sh"

echo "Done $0"


<reponame>zhihui-slash2/slash2-stable
#!/usr/bin/env bash
# $Id$

prog=mount_slash
ctl=msctl

. $(dirname $0)/pfl_daemon.sh

usage()
{
	echo "usage: $0 [-dgOv] [-F filter] [-P deployment-profile] [instance]" >&2
	exit 1
}

bkav=("$@")
while getopts "dF:gOP:v" c; do
	case $c in
	d) nodaemonize=1	;;
	F) filter=$OPTARG	;;
	g) filter=mygdb		;;
	O) once=1		;;
	P) prof=$OPTARG		;;
	v) verbose=1		;;
	*) usage		;;
	esac
done
shift $(($OPTIND - 1))

xargs=()
apply_host_prefs "$@"

: ${mp:=/$prof}
umount -l -f $mp 2>/dev/null
[ -d $mp ] || mkdir -p $mp
base=$dir/$prof.s2
# Initialization/configuration
ulimit -n 100000
ulimit -c $((1024 * 1024 * 1024 * 50))
export LD_LIBRARY_PATH=/usr/local/lib
export PSC_SYSLOG_info=1
export PSC_LOG_LEVEL=${PSC_LOG_LEVEL:-notice}
export PSC_LOG_LEVEL_info=info
export PSC_LOG_FILE=${PSC_LOG_FILE:-$base/log/$host.$name/%t}
export PSC_LOG_FILE_LINK=$(dirname $PSC_LOG_FILE)/latest
export CONFIG_FILE=$base/slcfg

type modprobe >/dev/null 2>&1 && modprobe fuse

rundaemon $filter $prog -D $base/var -U ${xargs[@]} $mp


<reponame>jtullos-intel/SENA-c_sw<gh_stars>0
#!/bin/bash

set -e

# Check usage
if [ $# -ne 2 ]; then
  echo "Usage: build.sh gcc|intel debug|release"
  exit 1
fi

# Get arguments
COMPILER=$1
BUILD_TYPE=$2

# Start with a clean module environment
module purge

# Handle compiler settings
case ${COMPILER} in
  "gcc"|"gnu" )
    export CC=gcc
    export FC=gfortran
    module load gcc 2>/dev/null || module load gnu
  ;;
  "intel" )
    export CC=icc
    export FC=ifort
    module load intel
  ;;
  *)
    echo "Unsupported compiler: ${COMPILER}"
    exit 1
  ;;
esac

# Handle build type
case ${BUILD_TYPE} in
  "debug"|"release" )
    echo "Building with ${COMPILER} in ${BUILD_TYPE} mode"
  ;;
  *)
    echo "Unsupported build type: ${BUILD_TYPE}"
    exit 1
  ;;
esac

# Print out modules in use
module load netcdf cmake
module list

# Create build dir
rm -rf build
mkdir build
cd build

# Build
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ..
make -j4 VERBOSE=1

# Run the test suite
export OMP_NUM_THREADS=4
ctest


<gh_stars>0
#!/bin/bash

#SBATCH -p veu # Partition to submit to
#SBATCH --gres=gpu:0
#SBATCH --mem=50G # Memory
#SBATCH --ignore-pbs
#SBATCH --output=decode_layer0.log

#WORKING_DIR="/veu4/usuaris31/mruiz/large-projections/corpus/"
#SRC="en"
#TGT="tr"
#DEST_DIR="data-bin/wmt17.tokenized.16k.tr-en"
#CP_DIR="checkpoints/entr-interlingua"
#CP="checkpoint62.pt"

#WORKING_DIR="/veu4/usuaris31/mruiz/large-projections/corpus/"
#SRC="de"
#TGT="en"
#DEST_DIR="data-bin/wmt13.tokenized.32k.de-en"
#CP_DIR="checkpoints/add-lang-deen"
#CP="checkpoint_best.pt"
LAYER=0

#stdbuf -i0 -e0 -o0 python generate_decoder_layer.py  $DEST_DIR --path $CP_DIR/$CP  --beam 1 --batch-size 1 --source-lang $SRC --target-lang $TGT --task multilingual_translation --output-file ../vectors-elora/interlingua-distance/decodings-layer${LAYER}/decodings-${SRC}-${LAYER}.json --n-points 200 --layer $LAYER

WORKING_DIR="/veu4/usuaris31/mruiz/large-projections/corpus/"
SRC="fr"
TGT="en"
DEST_DIR="data-bin/wmt13.tokenized.32k.fr-en"
CP_DIR="checkpoints/add-lang-fren"
CP="checkpoint_best.pt"

#CUDA_VISIBLE_DEVICES="" stdbuf -i0 -e0 -o0 python generate_decoder_layer.py  $DEST_DIR --path $CP_DIR/$CP  --beam 1 --batch-size 1 --source-lang $SRC --target-lang $TGT --task multilingual_translation --output-file ../vectors-elora/interlingua-distance/decodings-layer${LAYER}/decodings-${SRC}-${LAYER}.json --n-points 3000 --layer $LAYER

#CUDA_VISIBLE_DEVICES="" stdbuf -i0 -e0 -o0 python generate_decoder_layer.py data-bin/wmt13.tokenized.32k.en-es --path checkpoints/esen-interlingua-finetuning/$CP  --beam 1 --batch-size 1 --source-lang es --target-lang en --task interlingua_translation --output-file ../vectors-elora/interlingua-distance/decodings-layer${LAYER}/decodings-esen-${LAYER}.json --n-points 3000 --layer $LAYER

#CUDA_VISIBLE_DEVICES="" stdbuf -i0 -e0 -o0 python generate_decoder_layer.py data-bin/wmt13.tokenized.32k.en-es --path checkpoints/esen-interlingua-finetuning/$CP  --beam 1 --batch-size 1 --source-lang en --target-lang es --task interlingua_translation --output-file ../vectors-elora/interlingua-distance/decodings-layer${LAYER}/decodings-enes-${LAYER}.json --n-points 3000 --layer $LAYER

CUDA_VISIBLE_DEVICES="" stdbuf -i0 -e0 -o0 python generate_decoder_layer.py ../fairseq/data-bin/multi-europarl --path checkpoints/esen-interlingua-finetuning/$CP  --beam 1 --batch-size 1 --source-lang es --target-lang es --task interlingua_translation --output-file ../vectors-elora/interlingua-distance/decodings-layer${LAYER}/decodings-eses-${LAYER}.json --n-points 3000 --layer $LAYER

CUDA_VISIBLE_DEVICES="" stdbuf -i0 -e0 -o0 python generate_decoder_layer.py data-bin/wmt13.tokenized.32k.en-es --path checkpoints/esen-interlingua-finetuning/$CP  --beam 1 --batch-size 1 --source-lang en --target-lang en --task interlingua_translation --output-file ../vectors-elora/interlingua-distance/decodings-layer${LAYER}/decodings-enen-${LAYER}.json --n-points 3000 --layer $LAYER

#stdbuf -i0 -e0 -o0 python visualization/preProcessData.py en  decodings-enen.json $WORKING_DIR/newstest2013.tc.en \
# fr decodings-fr.json $WORKING_DIR/newstest2013.tc.fr 200 data_fren.json

#stdbuf -i0 -e0 -o0 python visualization/preProcessData.py en  decodings-enen.json $WORKING_DIR/newstest2013.tc.en \
# de decodings-de.json $WORKING_DIR/newstest2013.tc.de 200 data_deen.json

#stdbuf -i0 -e0 -o0 python visualization/preProcessData.py es  decodings-eses.json $WORKING_DIR/newstest2013.tc.es \
# fr decodings-fr.json $WORKING_DIR/newstest2013.tc.fr 200 data_fres.json

#stdbuf -i0 -e0 -o0 python visualization/preProcessData.py es  decodings-eses.json $WORKING_DIR/newstest2013.tc.es \
# de decodings-de.json $WORKING_DIR/newstest2013.tc.de 200 data_dees.json

#stdbuf -i0 -e0 -o0 python visualization/preProcessData.py es  decodings-eses.json $WORKING_DIR/newstest2013.tc.es \
# es decodings-enes.json $WORKING_DIR/newstest2013.tc.es 200 data_enesauto.json

#stdbuf -i0 -e0 -o0 python visualization/preProcessData.py en  decodings-enen.json $WORKING_DIR/newstest2013.tc.en \
# en decodings-esen.json $WORKING_DIR/newstest2013.tc.en 200 data_esenauto.json


<filename>network-manager-customsettings/etc/NetworkManager/dispatcher.d/defaultprinter.sh
#!/bin/bash
PRINTERSCRIPT=/usr/bin/nm-defaultprinter.py
UPDATESCRIPT=/usr/bin/nm-updatecheck.py
DEFAULTPRINTER="PDF"
echo $CONNECTION_ID $CONNECTION_UUID $CONNECTION_FILENAME $2

## Funktionen durchführen, je nach Aktion eine andere
case "$2" in
	pre-up)
		;;

        up)
		$PRINTERSCRIPT -i "$CONNECTION_ID" -C
		#$UPDATESCRIPT -i "$CONNECTION_ID" -C
                ;;

        pre-down)
		;;

	down)
		#echo "DOWN DEFAULTPRINTER: " $(lpstat -d|awk '{print $NF}')
		$PRINTERSCRIPT -i "$CONNECTION_ID" -S -p $(lpstat -d|awk '{print $NF}')
		$PRINTERSCRIPT -C
		#$UPDATESCRIPT -C
                ;;

	vpn-pre-up)
		;;

	vpn-up)
		;;

	vpn-pre-down)
		;;

	vpn-down)
		;;

	hostname)
		;;

	dhcp4-change)
		;;

	dhcp6-change)
		;;

	connectivity-change)
		#echo "CC DEFAULTPRINTER: " $(lpstat -d|awk '{print $NF}')
		;;

       *)
                echo $"Usage: $0 <interface> {pre-up|up|pre-down|down|vpn-pre-up|vpn-up|vpn-pre-down|vpn-down|hostname|dhcp4-change|dhcp6-change}"
		echo $"<interface> = {eth[0-9]|wlan[0-9]}"
                exit 1
esac

exit 0

#nmcli  con show --active
activ_con=($(nmcli -t -f UUID con show --active ))
[[ x"${activ_con[0]}" = "x" ]] && active_con=default


#!/usr/bin/env sh
# Don't use the default mirrors for the initial upgrade
echo -e 'Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch\nServer = http://ftp.snt.utwente.nl/pub/os/linux/archlinux/$repo/os/$arch' > /etc/pacman.d/mirrorlist

pacman -Sy archlinux-keyring --noconfirm --needed
pacman -Sy --noconfirm

pacman -S ruby python2 python3 rsync git icu puppet acl libmariadbclient nodejs base-devel iputils wget unzip screen --noconfirm --needed
puppet module install puppetlabs-vcsrepo
puppet module install maestrodev-wget
puppet module install saz-sudo --version=4.2.0

# Make sure the kernel is not upgraded on 'pacman -Syu' because otherwise we'd need to reboot
# yet again before docker will work inside the virtualized guest due to the right veth kernel module
# not being able to be loaded.  Workaround for:
# docker: Error response from daemon: failed to create endpoint ... on network bridge:
# failed to add the host (...) <=> sandbox (...) pair interfaces: operation not supported.
grep -q "IgnorePkg = linux" "/etc/pacman.conf" || sed -i '/\[options\]/a IgnorePkg = linux' /etc/pacman.conf


<reponame>seanbreckenridge/dotfiles
# under certain (interactive, basic) conditions, upgrade a command
# to a fancy version

# if I type python with out any arguments, launch ipython instead
python() {
	python3 "$@"
}
python3() {
	if (($# == 0)); then
		echo -e "$(tput setaf 2)Launching ipython instead...$(tput sgr0)"
		ipython
	else
		command python3 "$@"
	fi
}

# https://github.com/odeke-em/drive
# if I run drive outside my google drive
# move to ~/GoogleDrive/
drive() {
	local defaultdrive="${HOME}/GoogleDrive"

	# early exit if drive doesnt exist where I expect
	[[ ! -r "${defaultdrive}" ]] && command drive "$@"

	# if not trying to create another google drive instance
	if [[ "$1" != 'init' ]]; then
		if ! grep -q "${defaultdrive}" <<<"${PWD}"; then
			cd "${defaultdrive}" || {
				printf "Couldnt change directory to %s\n" "${defaultdrive}"
			}
		fi
	fi
	command drive "$@"
}

# https://github.com/charmbracelet/glow
glow() {
	# if passed with no arguments
	# and theres only one .md file in this
	# directory, automatically use it
	if (($# == 0)); then
		local -a MD_FILES
		MD_FILES=()
		while IFS= read -r file; do
			MD_FILES+=("$file")
		done < <(find . -maxdepth 1 -name '*.md')
		if [[ "${#MD_FILES[@]}" == "1" ]]; then
			command glow "${MD_FILES[*]}"
		else
			command glow "$@"
		fi
	else
		command glow "$@"
	fi
}