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

#
# src/test/tools/anonymous_mmap/check_max_mmap.sh -- checks how many DAX
#               devices can be mapped under Valgrind and saves the number in
#               src/test/tools/anonymous_mmap/max_dax_devices.
#

DIR_CHECK_MAX_MMAP="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
FILE_MAX_DAX_DEVICES="$DIR_CHECK_MAX_MMAP/max_dax_devices"
ANONYMOUS_MMAP="$DIR_CHECK_MAX_MMAP/anonymous_mmap.static-nondebug"

source "$DIR_CHECK_MAX_MMAP/../../testconfig.sh"

#
# get_devdax_size -- get the size of a device dax
#
function get_devdax_size() {
	local device=$1
	local path=${DEVICE_DAX_PATH[$device]}
	local major_hex=$(stat -c "%t" $path)
	local minor_hex=$(stat -c "%T" $path)
	local major_dec=$((16#$major_hex))
	local minor_dec=$((16#$minor_hex))
	cat /sys/dev/char/$major_dec:$minor_dec/size
}

function msg_skip() {
	echo "0" > "$FILE_MAX_DAX_DEVICES"
	echo "$0: SKIP: $*"
	exit 0
}

function msg_failed() {
	echo "$0: FATAL: $*" >&2
	exit 1
}

# check if DEVICE_DAX_PATH specifies at least one DAX device
if [ ${#DEVICE_DAX_PATH[@]} -lt 1 ]; then
	msg_skip "DEVICE_DAX_PATH does not specify path to DAX device."
fi

# check if valgrind package is installed
VALGRINDEXE=`which valgrind 2>/dev/null`
ret=$?
if [ $ret -ne 0 ]; then
	msg_skip "Valgrind required."
fi

# check if memcheck tool is installed
$VALGRINDEXE --tool=memcheck --help 2>&1 | grep -qi "memcheck is Copyright (c)" && true
if [ $? -ne 0 ]; then
	msg_skip "Valgrind with memcheck required."
fi

# check if anonymous_mmap tool is built
if [ ! -f "${ANONYMOUS_MMAP}" ]; then
	msg_failed "${ANONYMOUS_MMAP} does not exist"
fi

# checks how many DAX devices can be mmapped under Valgrind and save the number
# in $FILE_MAX_DAX_DEVICES file
bytes="0"
max_devices="0"
for index in ${!DEVICE_DAX_PATH[@]}
do
	if [ ! -e "${DEVICE_DAX_PATH[$index]}" ]; then
		msg_failed "${DEVICE_DAX_PATH[$index]} does not exist"
	fi

	curr=$(get_devdax_size $index)
	if [[ curr -eq 0 ]]; then
		msg_failed "size of DAX device pointed by DEVICE_DAX_PATH[$index] equals 0."
	fi

	$VALGRINDEXE --tool=memcheck --quiet $ANONYMOUS_MMAP $((bytes + curr))
	status=$?
	if [[ status -ne 0 ]]; then
		break
	fi

	bytes=$((bytes + curr))
	max_devices=$((max_devices + 1))
done

echo "$max_devices" > "$FILE_MAX_DAX_DEVICES"

echo "$0: maximum possible anonymous mmap under Valgrind: $bytes bytes, equals to size of $max_devices DAX device(s). Value saved in $FILE_MAX_DAX_DEVICES."


<reponame>vpsx/paoloserver
# I have no idea what I am doing
# With help from github.com/mikegcoleman/todo#docker-containers-with-docker-compose

# install latest version of docker the lazy way
curl -sSL https://get.docker.com | sh

# make it so you don't need to sudo to run docker commands
usermod -aG docker ubuntu

# install docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

# run the thing
# docker run -t -p 80:5000 vpsx/paoloserver:latest
docker-compose up -d


<filename>install_rpmfusion.sh
#!/bin/bash
sudo dnf install -y \
  https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm

sudo dnf install -y \
  https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm


<filename>.scripts/pre-commit.sh
####
## @file
## Run pre-commit dependencies (minifying CSS and JavaScript files, mostly) and then do a quick jekyll build.
##
## This script requires that you install some node.js dependencies by running:
##   `npm install`
## from the repo root.
##
## Run this script from the repo root (ex: `.scripts/pre-commit.sh`).
####

npm run prettier-css
npm run prettier-js
npm run purgecss
npm run terser
bundle exec jekyll build --verbose


#!/bin/sh
JUMPGATE_CONFIG=etc/jumpgate.conf gunicorn "jumpgate.wsgi:make_api()" --bind="10.114.252.140:5000" --timeout=600 --access-logfile="-" -w 4 $@;


<filename>test/z80/run.sh
#!/bin/sh
function test {
	echo Testing $i
	../../build/scons/build_gameboy/motorgb -mcz -fv -o$1.r $1 >$1.out 2>&1
	cat $1.r $1.out >$1.output 2>/dev/null
	rm $1.r $1.out 2>/dev/null
	diff $1.output $1.answer
	if [ $? -eq 0 ]; then
		rm $1.output
	fi
}

for i in *.asm; do
	test $i
done


<filename>toolkit/compile.sh
#!/bin/sh
rm -rf bin
mkdir bin
javac -cp bin -d bin src/toolkit/StringUtil.java
javac -cp bin -d bin src/toolkit/Calc.java
javac -cp bin -d bin src/toolkit/Dado.java
javac -cp bin -d bin src/toolkit/DadoAbstrato.java
javac -cp bin -d bin src/toolkit/Dado6Faces.java
javac -cp bin -d bin src/toolkit/Dado18Faces.java
javac -cp bin -d bin src/toolkit/Dado2x6Faces.java
javac -cp bin -d bin src/toolkit/DadoViciado.java
javac -cp bin -d bin src/toolkit/DadoEmDobro.java
javac -cp bin -d bin src/toolkit/Main.java
javac -cp bin -d bin src/toolkit/UmJogo.java


<reponame>ArcadeAnalytics/arcadeanalytics-docker-images
#!/usr/bin/env bash

docker build --pull . -t arcadeanalytics/postgres-dvdrental

docker push arcadeanalytics/postgres-dvdrental


<gh_stars>1-10
narchi_cli.py render --ext_vars '{"vocabulary_size": 5000}' text_image_classification.jsonnet;


<gh_stars>0
#!/bin/bash
# Author: <NAME> (MPED)
# Description: This script builds a docker image and optionally uploads it to Docker Hub
# Please do not depend on my Docker Hub image, rather fork it yourself.
# You want to have $DOCKER_ID_USER set correctly if you want to push to your own Docker Hub repo!
# It takes around 30mins to complete --setup_foreigns --setup_chroots --push --fetch_all --build_all

IMAGE_V0=debian:stretch-slim              # Input: Some small Debian [AMD64] (or other distro which has debootstrap)
IMAGE_V1=debian_foreign_base              # Output: Debian [AMD64] containing other Debians of differing architectures via schroot
IMAGE_V2=debian_foreign                   # Output: Same as IMAGE_V1 with chroots being populated with packages
IMAGE_V3=debian_foreign_fetched           # Output: Same as IMAGE_V2 with zephyr having been fetched
IMAGE_V4=debian_foreign_built             # Output: Same as IMAGE_V3 with zephyr having been built

DOCKER_RUN_OPTS="--privileged -v ${PWD}:/this_dir -it"

function docker_commit
{
    local image_from="$1"
    local image_to="$2"

    # Get ID of the previous exited instance of $image_from
    container_id=$(sudo docker container ls --all --quiet --latest --filter ancestor=${image_from} --filter status=exited)

    # Commit that container instance to a new image, call it $image_to
    sudo docker commit -m"Debian with another foreign debians inside it" ${container_id} ${image_to}
}

### Run: Install base image for each architecture and setup chroots
if [[ "$@" == *"--setup_foreigns"* ]]; then
    # Run the base image, with this directory bind-mounted inside, then run script.
    # The script setup_foreigns.sh will install the foreign userlands etc
    sudo docker run                        \
        ${DOCKER_RUN_OPTS}                 \
        ${IMAGE_V0}                        \
        bash -x /this_dir/inside_docker/setup_foreigns.sh

    docker_commit ${IMAGE_V0} ${IMAGE_V1}
fi

### Run: Under every architecture's chroot, install some packages
if [[ "$@" == *"--setup_chroots"* ]]; then
    sudo docker run                        \
        ${DOCKER_RUN_OPTS}                 \
        ${IMAGE_V1}                        \
        bash -x /this_dir/inside_docker/for_each_arch.sh bash -x /docker_root/this_dir/inside_docker/inside_chroots/setup_chroot.sh

    # TODO: Test if setup_chroot executed correctly

    docker_commit ${IMAGE_V1} ${IMAGE_V2}
fi

### Push the clean image
if [[ "$@" == *"--push"* ]]; then
    # Then push
    sudo docker tag ${IMAGE_V2} ${DOCKER_ID_USER:-mpedoticon}/${IMAGE_V2}
    sudo docker push ${DOCKER_ID_USER:-mpedoticon}/${IMAGE_V2}
fi

### Run: Under every architecture's chroot, fetch zephyr
if [[ "$@" == *"--fetch_all"* ]]; then
    sudo docker run                        \
        ${DOCKER_RUN_OPTS}                 \
        ${IMAGE_V2}                        \
        bash -x /this_dir/inside_docker/for_each_arch.sh bash -x /docker_root/this_dir/inside_docker/inside_chroots/zephyr.sh fetch_all

    # TODO: Test if payload executed correctly

    docker_commit ${IMAGE_V2} ${IMAGE_V3}
fi

### Run: Under every architecture's chroot, build zephyr
if [[ "$@" == *"--build_all"* ]]; then
    sudo docker run                        \
        ${DOCKER_RUN_OPTS}                 \
        ${IMAGE_V3}                        \
        bash -x /this_dir/inside_docker/for_each_arch.sh bash -x /docker_root/this_dir/inside_docker/inside_chroots/zephyr.sh build_all

    # TODO: Test if payload executed correctly

    docker_commit ${IMAGE_V3} ${IMAGE_V4}
fi

### Run: Let user play around in the last image
if [[ "$@" == *"--interactive"* ]]; then
    sudo docker run                        \
        ${DOCKER_RUN_OPTS}                 \
        ${IMAGE_V4}                        \
        bash
fi


#!/usr/bin/env bash

./tests/bootstrap-examples/empty.sh major-version-up && \
(
  cd sandbox/major-version-up && \
  git add . && git commit -m "initial commit" && \
  git tag v0.0.1 && \
  touch a && \
  git add a && git commit -m "feat: add a" -m "BREAKING CHANGE: this breaks the previous behavior."
)


<gh_stars>0
#!/bin/bash
clear
echo -e "════════════════════════════════════════════════════════════
=             Script Vps For Debian N Ubuntu   "
echo -e ""
echo -e "\e[94m  .----------------------------------------------------.    "
echo -e "\e[94m  |                        SSTP MENU                   |    "
echo -e "\e[94m  '----------------------------------------------------'    "
echo -e "\e[0m                                                               "
echo -e "\e[1;31m* [1]\e[0m \e[1;32m: Create Account SSTP\e[0m\e[0m"
echo -e "\e[1;31m* [2]\e[0m \e[1;32m: Delete SSTP Account\e[0m\e[0m"
echo -e "\e[1;31m* [3]\e[0m \e[1;32m: Extending SSTP Account Active Life\e[0m"
echo -e "\e[1;31m* [4]\e[0m \e[1;32m: Check User Login SSTP\e[0m"
echo -e ""
echo -e ""
read -p "        Select From Options [1-4 or x]: " menusstp
echo -e ""
case $menusstp in
1)
add-sstp
;;
2)
del-sstp
;;
3)
renew-sstp
;;
4)
cek-sstp
;;
x)
menu
;;
*)
echo " Please enter an correct number!!"
;;
esac


<reponame>vladfr/gosaas<filename>client/proto.sh<gh_stars>0
#!/bin/bash

OUT_DIR=src/proto/

protoc \
  --js_out=import_style=commonjs,binary:$OUT_DIR \
  --grpc-web_out=import_style=typescript,mode=grpcwebtext:$OUT_DIR \
  -I ../server  ../server/*/*.proto


<!
	description: A game of hockey where two teams fight to knock a slime into the opponent's goal.;

	requiredExtensions: SKCompat;
	requiredProcs: _add_activity() and _remove_activity() procedures to keep a list of all current activities on server.
>
register_command('hockey', array(
	'description': 'Starts a hockey game.',
	'usage': '/hockey',
	'tabcompleter': closure(@alias, @sender, @args, @info) {
		return(array());
	},
	'executor': closure(@alias, @sender, @args, @info) {
		if(array_contains(get_scoreboards(), 'hockey')) {
			die(color('gold').'Hockey already running.');
		}

		@players = array();
		foreach(@p in all_players(pworld())) {
			if(array_contains(sk_current_regions(@p), 'hockey')) {
				@players[] = @p;
			}
		}
		if(array_size(@players) < 1) {
			die(color('gold').'Not enough players.');
		} else if(array_size(@players) % 2 == 1) {
			//die('Teams are not even.');
		}

		proc _queue_game(@players) {
			_add_activity('hockey', 'Ice Hockey');
			@red = associative_array('name': 'RED_STAINED_GLASS_PANE');
			@blue = associative_array('name': 'BLUE_STAINED_GLASS_PANE');
			@hockey = associative_array(
				'players': @players,
				'puck': '',
				'velocity': associative_array(),
				'holder': '',
				'distance': 0,
				'last': '',
				'seconds': 180,
				'red': '',
				'blue': '',
				'loc': associative_array(),
				'lastloc': associative_array(),
				'redgear': associative_array(
					4: @red, 5: @red, 6: @red, 7: @red, 8: @red,
					100: associative_array('name': 'LEATHER_BOOTS', 'meta': associative_array('color': array(255, 0, 0))),
					101: associative_array('name': 'LEATHER_LEGGINGS', 'meta': associative_array('color': array(255, 0, 0))),
					102: associative_array('name': 'LEATHER_CHESTPLATE', 'meta': associative_array('color': array(255, 0, 0))),
					103: associative_array('name': 'LEATHER_HELMET', 'meta': associative_array('color':array(255, 0, 0))),
				),
				'bluegear': associative_array(
					4: @blue, 5: @blue, 6: @blue, 7: @blue, 8: @blue,
					100: associative_array('name': 'LEATHER_BOOTS', 'meta': associative_array('color': array(0, 0, 255))),
					101: associative_array('name': 'LEATHER_LEGGINGS', 'meta': associative_array('color': array(0, 0, 255))),
					102: associative_array('name': 'LEATHER_CHESTPLATE', 'meta': associative_array('color': array(0, 0, 255))),
					103: associative_array('name': 'LEATHER_HELMET', 'meta': associative_array('color': array(0, 0, 255))),
				),
				'width': 'z',
			);
			@hockey['players'] = @players;

			// create scoreboard
			create_scoreboard('hockey');
			create_objective('score', 'dummy', 'hockey');
			set_objective_display('score', associative_array('slot': 'SIDEBAR', 'displayname': color('bold').'Score'), 'hockey');

			@hockey['red'] = color('red').array_get_rand(array('StoneRiver Toads', 'Utah Waffles', '<NAME>', 'Oakdale Furies'));
			create_team('red', 'hockey');
			set_team_display('red', array('displayname': @hockey['red'], 'color': 'RED'), 'hockey');
			set_pscore('score', @hockey['red'], 0, 'hockey');

			@hockey['blue'] = color('blue').array_get_rand(array('Gothem Knights', 'Stirling Kings', 'PantsCo Pixies', 'Canada Wizards'));
			create_team('blue', 'hockey');
			set_team_display('blue', array('displayname': @hockey['blue'], 'color': 'BLUE'), 'hockey');
			set_pscore('score', @hockey['blue'], 0, 'hockey');

			@t = 0;
			@world = '';
			foreach(@p in array_rand(@players, array_size(@players), false)) {
				@world = pworld(@p);
				set_pscoreboard(@p, 'hockey');
				if(@t) {
					team_add_player('red', @p, 'hockey');
					@t = 0;
					set_pinv(@p, @hockey['redgear']);
				} else {
					team_add_player('blue', @p, 'hockey');
					@t = 1;
					set_pinv(@p, @hockey['bluegear']);
				}
				set_pheld_slot(@p, 0);
			}

			// get puck spawn point
			@region = sk_region_info('hockey', @world, 0);
			@hockey['loc'] = associative_array(
				'x': (@region[0][0] + @region[1][0]) / 2 + 0.5,
				'y': @region[1][1] + 0.078,
				'z': (@region[0][2] + @region[1][2]) / 2 + 0.5,
				'world': @world
			);
			if(@region[0][0] - @region[1][0] < @region[0][2] - @region[1][2]) {
				@hockey['width'] = 'x';
			}

			@countdown = array(5);
			set_interval(1000, closure(){
				play_sound(@hockey['loc'], associative_array('sound': 'BLOCK_NOTE_BLOCK_PLING', 'volume': 2, 'pitch': @countdown[0]));
				if(@countdown[0] > 0) {
					@countdown[0]--;
				} else {
					clear_task();
					_start_game(@hockey);
				}
			});
		}

		proc _start_game(@hockey) {
			_place_puck(@hockey);

			// bind events
			bind('entity_damage', associative_array('id': 'hockey-damage'), associative_array('id': @hockey['puck']), @event, @hockey) {
				if(!array_index_exists(@event, 'damager')) {
					@hockey['holder'] = '';
					set_entity_loc(@hockey['puck'], @hockey['lastloc']);
					die();
				}
				cancel();
				@xp = 30;
				if(@event['damager'] == @hockey['holder']) {
					@xp = max(1, (pexp(@event['damager']) / 2) ** 1.25);
				}
				@player = @event['damager'];
				play_sound(entity_loc(@event['id']), array('sound': 'BLOCK_WOODEN_BUTTON_CLICK_ON', 'pitch': 2 - (1.3 / @xp)));
				@ploc = entity_loc(puuid(@player));
				@eloc = entity_loc(@hockey['puck']);
				@dist = distance(@ploc, @eloc);
				@x = ((@eloc['x'] - @ploc['x']) / @dist) * (@xp / 50);
				@z = ((@eloc['z'] - @ploc['z']) / @dist) * (@xp / 50);
				@hockey['velocity'] = array('x': @x, 'y': 0, 'z': @z);
				set_entity_velocity(@hockey['puck'], @hockey['velocity']);
				@hockey['last'] = @player;
				@hockey['holder'] = '';
			}
			bind('player_interact_entity', associative_array('id': 'hockey-interact'), null, @event, @hockey) {
				if(@event['id'] != @hockey['puck']) {
					die();
				}
				@ploc = ploc();
				@eloc = entity_loc(@hockey['puck']);
				@ploc['y'] += 1;
				@dist = distance(@ploc, @eloc);
				if(@dist < 3.5) {
					@hockey['holder'] = player();
					@hockey['last'] = player();
					@hockey['distance'] = @dist;
					@hockey['velocity'] = associative_array('x': 0, 'y': 0, 'z': 0);
					@hockey['lastloc'] = entity_loc(@hockey['puck']);
					set_pexp(0);
					play_sound(@eloc, array('sound': 'BLOCK_WOODEN_BUTTON_CLICK_ON', 'pitch': 0.6));
				}
			}
			bind('entity_damage_player', associative_array('id': 'hockey-damage-player'), associative_array('damager': 'PLAYER'), @event, @hockey) {
				if(@hockey['holder'] == player()) {
					set_pexp(@hockey['holder'], 0);
					@hockey['holder'] = '';
				}
			}
			bind('player_quit', associative_array('id': 'hockey-quit'), null, @event, @hockey) {
				if(array_contains(@hockey['players'], player())) {
					array_remove_values(@hockey['players'], player());
					@team = get_pteam(player(), 'hockey');
					team_remove_player(@team['name'], player(), 'hockey');
					if(array_size(@team['players']) < 2) {
						_end_game(@hockey);
					}
					if(@hockey['holder'] == player()) {
						_place_puck(@hockey);
					}
				}
			}
			bind('target_player', associative_array('id': 'hockey-target'), associative_array('mobtype': 'SLIME'), @event, @hockey) {
				if(@event['id'] == @hockey['puck']) {
					modify_event('player', null);
				}
			}

			// core game loop
			@count = array(20);
			@bounciness = 0.85;
			@world = @hockey['loc']['world'];
			set_interval(50, 0, closure(){
				if(--@count[0] == 0) {
					@count[0] = 20;
					@hockey['seconds']--;
					@time = simple_date('m:ss', @hockey['seconds'] * 1000);
					foreach(@p in all_players(@world)) {
						if(array_contains(sk_current_regions(@p), 'hockey')) {
							if(!array_contains(@hockey['players'], @p)) {
								@hockey['players'][] = @p;
								@teams = get_teams('hockey');
								if(array_size(@teams['red']['players']) > array_size(@teams['blue']['players'])) {
									team_add_player('blue', @p, 'hockey');
									set_pinv(@p, @hockey['bluegear']);
								} else {
									team_add_player('red', @p, 'hockey');
									set_pinv(@p, @hockey['redgear']);
								}
								set_pheld_slot(@p, 0);
								set_pscoreboard(@p, 'hockey');
							}
							action_msg(@p, @time);
							set_peffect(@p, 'JUMP_BOOST', -6, 2, false, false);
						} else if(array_contains(@hockey['players'], @p)) {
							array_remove_values(@hockey['players'], @p);
							@team = get_pteam(@p, 'hockey');
							team_remove_player(@team['name'], @p, 'hockey');
							if(array_size(@team['players']) < 2) {
								_end_game(@hockey);
								die();
							}
						}
					}
					if(@hockey['seconds'] < 1) {
						_end_game(@hockey);
						die();
					}
				}

				if(!entity_exists(@hockey['puck'])) {
					_end_game(@hockey);
					die();
				}

				@l = entity_loc(@hockey['puck']);
				@block = get_block(location_shift(@l, 'down'));

				if(@block == 'RED_WOOL' || @block == 'BLUE_WOOL') {
					@team = if(@block == 'BLUE_WOOL', @hockey['red'], @hockey['blue']);
					set_pscore('score', @team, get_pscore('score', @team, 'hockey') + 1, 'hockey');
					launch_firework(@l, associative_array('strength': 0));
					_place_puck(@hockey);

				} else if(@block == 'STONE_SLAB') {
					@hockey['holder'] = '';
					set_entity_loc(@hockey['puck'], @hockey['lastloc']);

				} else if(@hockey['holder'] && (@block == 'ICE' || @block == 'PACKED_ICE')) {
					@newloc = ploc(@hockey['holder']);
					if(@newloc['world'] != @world) {
						_place_puck(@hockey);
					} else {
						if(@hockey['distance'] > 2.22) {
							@hockey['distance'] -= 0.03;
							set_pexp(@hockey['holder'], pexp(@hockey['holder']) + 1);
						} else if(@hockey['distance'] < 2.18) {
							@hockey['distance'] += 0.03;
							set_pexp(@hockey['holder'], pexp(@hockey['holder']) + 1);
						} else {
							set_pexp(@hockey['holder'], min(99, pexp(@hockey['holder']) + 2));
						}
						@vector = get_vector(ploc(@hockey['holder']), @hockey['distance']);
						@newloc['x'] += @vector['x'];
						@newloc['y'] += 1;
						@newloc['z'] += @vector['z'];
						set_entity_loc(@hockey['puck'], @newloc);
						@hockey['lastloc'] = @l;
					}

				} else {
					if(!array_contains(sk_regions_at(@l), 'hockey') || @l['y'] > @hockey['loc']['y']) {
						_place_puck(@hockey);
						die();
					}

					@v = entity_velocity(@hockey['puck']);
					@ricochetPitch = 0;

					@forceX = 0;
					if(@v['x'] == 0) {
						@forceX = abs(@hockey['velocity']['x']);
						@v['magnitude'] = 1;
						if(@forceX > 0.002) {
							@v['x'] = 0 - @hockey['velocity']['x'] * @bounciness;
							if(@forceX > 0.05) {
								@ricochetPitch = 1 + @forceX / 2;
							}
						}
					}

					if(@v['z'] == 0) {
						@forceZ = abs(@hockey['velocity']['z']);
						@v['magnitude'] = 1;
						if(@forceZ > 0.002) {
							@v['z'] = 0 - @hockey['velocity']['z'] * @bounciness;
							if(@forceZ > 0.06 && @forceZ > @forceX) {
								@ricochetPitch = 1 + @forceZ / 2;
							}
						}
					}

					if(@v['magnitude'] < 0.875 && @v['magnitude'] > 0.125) {
						@v['x'] = (@v['x'] / @v['magnitude']) * (1.08 * @v['magnitude']);
						@v['z'] = (@v['z'] / @v['magnitude']) * (1.08 * @v['magnitude']);
					}

					if(@ricochetPitch > 1) {
						play_sound(@l, array('sound': 'BLOCK_WOODEN_BUTTON_CLICK_ON', 'pitch': min(2, @ricochetPitch)));
					}

					@v['y'] = 0;
					@hockey['velocity'] = @v;
					set_entity_velocity(@hockey['puck'], @hockey['velocity']);
				}

			});
		}

		proc _place_puck(@hockey){
			@loc = @hockey['loc'][];
			@loc[@hockey['width']] += rand(5) - 2;
			if(!@hockey['puck']) {
				@hockey['puck'] = spawn_entity('SLIME', 1, @loc, closure(@e, set_entity_spec(@e, array('size': 1))))[0];
				set_timeout(1, closure(){
					set_mob_effect(@hockey['puck'], 'resistance', 4, 99999, true, false);
					set_mob_effect(@hockey['puck'], 'levitation', -1, 99999, true, false);
					set_mob_effect(@hockey['puck'], 'slowness', 10, 99999, true, false);
				});
			} else {
				set_entity_loc(@hockey['puck'], @loc);
			}
			@hockey['holder'] = '';
			@hockey['last'] = '';
			@hockey['velocity'] = associative_array('x': 0, 'y': 0, 'z': 0);
			set_entity_velocity(@hockey['puck'], @hockey['velocity']);
		}

		proc _end_game(@hockey){
			clear_task();
			unbind('hockey-damage');
			unbind('hockey-damage-player');
			unbind('hockey-interact');
			unbind('hockey-quit');
			unbind('hockey-target');
			@winner = null;
			@redscore = get_pscore('score', @hockey['red'], 'hockey');
			@bluescore = get_pscore('score', @hockey['blue'], 'hockey');
			@score = '';
			if(@redscore > @bluescore) {
				@winner = 'red';
				@score = @redscore.':'.@bluescore;
			} else if(@bluescore > @redscore) {
				@winner = 'blue';
				@score = @bluescore.':'.@redscore;
			} else {
				@score = @redscore.':'.@bluescore;
			}
			@msg = 'Tied game!';
			if(@winner) {
				@teams = get_teams('hockey');
				@msg = @teams[@winner]['displayname'].' won! '.color('bold').@score;
			}
			broadcast(@msg, @hockey['players']);
			remove_scoreboard('hockey');
			_remove_activity('hockey');
			entity_remove(@hockey['puck']);
		}

		_queue_game(@players);
	}
));


#!/bin/bash
#SBATCH --job-name=hello_world
#SBATCH --ntasks=4
#SBATCH --cpus-per-task=1
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=2
#SBATCH --time=00:05:00

export SCRATCH=/data/scratch/$USER
module load xalt2

srun --mpi=pmi2 python helloworld.py

python3 /data/relocate_xaltjson.py


<gh_stars>0
now_md5=$(md5sum < .circleci/config.yml)

set -eu
set -o pipefail

_basepath=$(eval echo "${CONFIG_DIR}")
_targets="${_basepath}/bases|${_basepath}/commands|${_basepath}/jobs|${_basepath}/workflows"

mkdir ./cmd
wget https://github.com/suzuki-shunsuke/circleci-config-merge/releases/download/v1.1.1/circleci-config-merge_1.1.1_linux_amd64.tar.gz -O - | tar zxvf - -C ./cmd
_cmd="./cmd/circleci-config-merge"
remerge_md5=$(git ls-files | grep -E "${_targets}" | xargs "${_cmd}" merge | md5sum)

echo "${now_md5}"
echo "${remerge_md5}"
if [ ! "${now_md5}" = "${remerge_md5}" ]; then
  echo "You forgot circleci-config-merge!"
  exit 1
fi


<reponame>oBusk/react-diff-view
yarn
yarn clean
export NODE_ENV=production
node rollup.js
node node_modules/.bin/postcss -o style/index.css src/styles/index.css
sed -i 's/}/;}/g' style/index.css


#!/bin/bash
# file: modules/jsshDB.sh
# do not edit, this file will be overwritten on update

# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.96-dev-7-g0153928
#
# source from commands.sh to use jsonDB functions
#
# jsonDB provides simple functions to read and store bash Arrays
# from to file in JSON.sh output format, its a simple key/value storage.

# source once magic, function named like file
eval "$(basename "${BASH_SOURCE[0]}")(){ :; }"

# new feature: serialize / atomic operations:
# updates will be done atomic with flock
# flock should flock should be availible on all system as its part of busybox
# tinybox

# lockfile filename.flock is persistent and will be testet with flock for active lock (file open)
export BASHBOT_LOCKNAME=".flock"

if _exists flock; then
  ###############
  # we have flock
  # use flock for atomic operations

  # read content of a file in JSON.sh format into given ARRAY
  # $1 ARRAY name, must be delared with "declare -A ARRAY" upfront
  # $2 filename, must be relative to BASHBOT_ETC, and not contain '..'
  jssh_readDB() {
	local DB; DB="$(jssh_checkDB "$2")"
	[ -z "${DB}" ] && return 1
	[ ! -f "${DB}" ] && return 2
	# shared lock, many processes can read, max wait 1s
	{ flock -s -w 1 200; Json2Array "$1" <"${DB}"; } 200>"${DB}${BASHBOT_LOCKNAME}"
  }

  # write ARRAY content to a file in JSON.sh format
  # Warning: old content is overwritten
  # $1 ARRAY name, must be delared with "declare -A ARRAY" upfront
  # $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
  jssh_writeDB() {
	local DB; DB="$(jssh_checkDB "$2")"
	[ -z "${DB}" ] && return 1
	[ ! -f "${DB}" ] && return 2
	# exclusive lock, no other process can read or write, maximum wait to get lock is 10s
	{ flock -e -w 10 200; Array2Json "$1" >"${DB}"; } 200>"${DB}${BASHBOT_LOCKNAME}"
  }

  # update/write ARRAY content in file without deleting keys not in ARRAY
  # $1 ARRAY name, must be delared with "declare -A ARRAY" upfront
  # $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
  jssh_updateDB() {
	# for atomic update we cant use read/writeDB
	local DB; DB="$(jssh_checkDB "$2")"
	[ -z "${DB}" ] && return 1
	[ ! -f "${DB}" ] && return 2

	declare -n ARRAY="$1"
	[ -z "${ARRAY[*]}" ] && return 1
	declare -A oldARR newARR

	# start atomic update here, exclusive max wait 10s
	{ flock -e -w 10 200
	Json2Array "oldARR" <"${DB}"
	if [ -z "${oldARR[*]}" ]; then
		# no old content
		Array2Json "$1" >"${DB}"
	else
		# merge arrays
		local o1 o2 n1 n2
		o1="$(declare -p oldARR)"; o2="${o1#*\(}"
		n1="$(declare -p ARRAY)";  n2="${n1#*\(}"
		unset IFS; set -f
		#shellcheck disable=SC2034,SC2190,SC2206
		newARR=( ${o2:0:${#o2}-1} ${n2:0:${#n2}-1} )
		set +f
		Array2Json  "newARR" >"${DB}"
	fi
	} 200>"${DB}${BASHBOT_LOCKNAME}"
  }

  # insert, update, apped key/value to jsshDB
  # $1 key name, can onyl contain -a-zA-Z0-9,._
  # $2 key value
  # $3 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
  jssh_insertDB() {
	[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
	local key="$1" value="$2"
	local DB; DB="$(jssh_checkDB "$3")"
	[ -z "${DB}" ] && return 1
	[ ! -f "${DB}" ] && return 2
	# start atomic update here, exclusive max wait 2, it's append, not overwrite
	{ flock -e -w 2 200
	 # it's append, but last one counts, its a simple DB ...
	  printf '["%s"]\t"%s"\n' "${key//,/\",\"}" "${value//\"/\\\"}" >>"${DB}"
	} 200>"${DB}${BASHBOT_LOCKNAME}"

  }

  # delete key/value from jsshDB
  # $1 key name, can onyl contain -a-zA-Z0-9,._
  # $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
  jssh_deleteKeyDB() {
	[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
	local DB; DB="$(jssh_checkDB "$2")"
	declare -A oldARR
	# start atomic delete here, exclusive max wait 10s
	{ flock -e -w 10 200
	Json2Array "oldARR" <"${DB}"
	unset oldARR["$1"]
	Array2Json  "oldARR" >"${DB}"
	} 200>"${DB}${BASHBOT_LOCKNAME}"
  }

  # delete key/value from jsshDB
  # $1 key name, can onyl contain -a-zA-Z0-9,._
  # $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
  jssh_getKeyDB() {
	[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
	local DB; DB="$(jssh_checkDB "$2")"
	declare -A oldARR
	# start atomic delete here, exclusive max wait 1s
	{ flock -e -w 1 200
	Json2Array "oldARR" <"${DB}"
	} 200>"${DB}${BASHBOT_LOCKNAME}"
	echo "${oldARR["$1"]}"
  }

  # add a value to key, used for conters
  # $1 key name, can onyl contain -a-zA-Z0-9,._
  # $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
  # $3 optional count, value added to count3r, add 1 if empty
  # side effect: if $3 is not given, we add to end of file to be as fast as possible
  jssh_countKeyDB() {
	[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
	local DB; DB="$(jssh_checkDB "$2")"
	declare -A oldARR
	# start atomic delete here, exclusive max wait 5
	{ flock -e -w 5 200
	Json2Array "oldARR" <"${DB}"
	if [ "$3" != "" ]; then
		(( oldARR["$1"]+="$3" ));
		Array2Json  "oldARR" >"${DB}"
	else
		# it's append, but last one counts, its a simple DB ...
		(( oldARR["$1"]++ ));
		printf '["%s"]\t"%s"\n' "${1//,/\",\"}" "${oldARR["$1"]//\"/\\\"}" >>"${DB}"
	fi
	} 200>"${DB}${BASHBOT_LOCKNAME}"
  }

else
  #########
  # we have no flock, use "old" not atomic functions
  jssh_readDB() {
	jssh_readDB_async "$@"
  }

  jssh_writeDB() {
	jssh_writeDB_async "$@"
  }

  jssh_updateDB() {
	jssh_updateDB_async "$@"
  }

  jssh_insertDB() {
	jssh_insertDB_async "$@"

  }

  jssh_deleteKeyDB() {
	jssh_deleteKeyDB_async "$@"
  }

  jssh_getKeyDB() {
	jssh_getKeyDB_async "$@"
  }
  jssh_countKeyDB() {
	jssh_countKeyDB "$@"
  }
fi

##############
# no need for atomic

# print ARRAY content to stdout instead of file
# $1 ARRAY name, must be delared with "declare -A ARRAY" upfront
jssh_printDB() {
	Array2Json "$1"
}

# get key/value from jsshDB
# $1 key name, can onyl contain -a-zA-Z0-9,._
# $2 key value
# $3 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
# returns value
jssh_getDB() {
	[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
	declare -A getARR
	jssh_readDB "getARR" "$3" || return "$?"
	printf '%s\n' "${getARR[${key}]}"
}

# $1 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
jssh_newDB() {
	local DB; DB="$(jssh_checkDB "$1")"
	[ -z "${DB}" ] && return 1
	[ -f "${DB}" ] && return 2 # already exist, do not zero out
	printf '\n' >"${DB}"
}

# $1 filename, check filename, it must be relative to BASHBOT_ETC, and not contain '..'
# returns real path to DB file if everything is ok
jssh_checkDB(){
	[ -z "$1" ] && return 1
	local DB="${BASHBOT_ETC:-.}/$1.jssh"
	if [[ "$1" = "${BASHBOT_ETC:-.}"* ]] || [[ "$1" = "${BASHBOT_DATA:-.}"* ]]; then
		DB="$1.jssh"
	fi
	[[ "$1" = *'..'* ]] && return 2
	printf '%s\n' "${DB}"
}

######################
# "old" implementations as non atomic functions
# can be used explictitly or as fallback if flock is not availible
jssh_readDB_async() {
	local DB; DB="$(jssh_checkDB "$2")"
	[ -z "${DB}" ] && return 1
	[ ! -f "${DB}" ] && return 2
	Json2Array "$1" <"${DB}"
}

jssh_writeDB_async() {
	local DB; DB="$(jssh_checkDB "$2")"
	[ -z "${DB}" ] && return 1
	[ ! -f "${DB}" ] && return 2
	Array2Json "$1" >"${DB}"
}

jssh_updateDB_async() {
	declare -n ARRAY="$1"
	[ -z "${ARRAY[*]}" ] && return 1
	declare -A oldARR newARR
	jssh_readDB_async "oldARR" "$2" || return "$?"
	if [ -z "${oldARR[*]}" ]; then
		# no old content
		jssh_writeDB_async "$1" "$2"
	else
		# merge arrays
		local o1 o2 n1 n2
		o1="$(declare -p oldARR)"; o2="${o1#*\(}"
		n1="$(declare -p ARRAY)";  n2="${n1#*\(}"
		unset IFS; set -f
		#shellcheck disable=SC2034,SC2190,SC2206
		newARR=( ${o2:0:${#o2}-1} ${n2:0:${#n2}-1} )
		set +f
		jssh_writeDB_async "newARR" "$2"
	fi
}

jssh_insertDB_async() {
	[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
	local key="$1" value="$2"
	local DB; DB="$(jssh_checkDB "$3")"
	[ -z "${DB}" ] && return 1
	[ ! -f "${DB}" ] && return 2
	# its append, but last one counts, its a simple DB ...
	printf '["%s"]\t"%s"\n' "${key//,/\",\"}" "${value//\"/\\\"}" >>"${DB}"

}

jssh_deleteKeyDB_async() {
	[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
	local DB; DB="$(jssh_checkDB "$2")"
	declare -A oldARR
	jssh_readDB_async "oldARR" "$2" || return "$?"
	unset oldARR["$1"]
	jssh_writeDB_async "oldARR" "$2"
}

jssh_getKeyDB_async() {
	[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
	local DB; DB="$(jssh_checkDB "$2")"
	declare -A oldARR
	Json2Array "oldARR" <"${DB}"
	echo "${oldARR["$1"]}"
}

jssh_countKeyDB_async() {
	[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
	local DB COUNT="1"; DB="$(jssh_checkDB "$2")"
	[ "$3" != "" ] && COUNT="$3"
	declare -A oldARR
	# start atomic delete here, exclusive max wait 10s
	Json2Array "oldARR" <"${DB}"
	(( oldARR["$1"]+=COUNT ));
	Array2Json  "oldARR" >"${DB}"
}


#!/bin/bash

# <EMAIL>
# 2015-Nov-03

# I bought a fancy USB keyboard with a built-in TrackPoint because I've
# lived long enough with a ThinkPad that I'm now one of "those people".
# I must seem very odd indeed to the Others at this point.

# The trouble is that, although middle-button + "nub" scrolling works on
# this USB keyboard, it also registers an unwanted middle-click. Disabling
# middle-button paste in the GNOME3 tweak tool helps to a degree, but it's
# still annoying in e.g. Thunderbird where middle-clicking a message in the
# inbox list opens that message in a new tab.

# Since this keyboard adds two identically-named devices, distinguishable
# only by their xinput device IDs, we have to bring in the dumb muscle of
# grep and awk in order to target the correct device. Boo.

# The correct device looks like this among the output of `xinput list`:
#
# Lenovo ThinkPad Compact USB Keyboard with TrackPoint	id=14	[slave  pointer  (2)]

DEVID=`xinput list | egrep 'Lenovo ThinkPad Compact USB Keyboard with TrackPoint.*slave.*pointer' | awk -F= '{ print $2 }' | awk '{ print $1 }'`

# Targeting the right device, we map its second (middle) button to act
# like button zero (no such button). Problem solved.

if [ ! -z $DEVID ]; then
	xinput set-button-map ${DEVID} 1 0 3
fi


<reponame>svenfuchs/simple_opts.sh<filename>shpec/shpec_helper.sh<gh_stars>10-100
# set -e

. lib/simple_opts.sh

end() {
  ((test_indent -= 2))
  if [ $test_indent -eq 0 ]; then
    [ $failures -eq 0 ]
  fi
}


#!/usr/bin/env bash

set -ue

source $(dirname "${BASH_SOURCE[0]:-$0}")/utilfuncs.sh

function install_fzf() {
  local fzf_dir="$HOME/.fzf"
  git_clone_or_fetch https://github.com/junegunn/fzf.git \
    $fzf_dir
  $fzf_dir/install --key-bindings --no-completion --no-update-rc
}

install_fzf


<gh_stars>0
source env-win32.sh
python chroniclr.py


#!/bin/bash
# Copyright      2017   <NAME>
#                2017   Johns Hopkins University (Author: <NAME>)
#                2017   Johns Hopkins University (Author: <NAME>)
#                2019   <NAME>. Modified to support network training using TensorFlow
# Apache 2.0.
#
#
# See README.txt for more info on data required.
# Results (mostly EERs) are inline in comments below.
#
# This example demonstrates a "bare bones" NIST SRE 2016 recipe using xvectors.
# In the future, we will add score-normalization and a more effective form of
# PLDA domain adaptation.
#
# Pretrained models are available for this recipe.
# See http://kaldi-asr.org/models.html and
# https://david-ryan-snyder.github.io/2017/10/04/model_sre16_v2.html
# for details.

. ./cmd.sh
. ./path.sh
set -e

fea_nj=32
nnet_nj=80

data_root=/home/heliang05/liuyi/sre.full/sre16_kaldi_list/
root=/home/heliang05/liuyi/sre.full/
data=$root/data
exp=$root/exp
mfccdir=$root/mfcc
vaddir=$root/mfcc

gender=pool

export sre10_dir=$data_root/sre10_eval/
export sre10_train_c5_ext=$sre10_dir/coreext_c5/enroll/$gender/
export sre10_trials_c5_ext=$sre10_dir/coreext_c5/test/$gender/
export sre10_train_10s=$sre10_dir/10sec/enroll/$gender/
export sre10_trials_10s=$sre10_dir/10sec/test/$gender/

export sre16_trials=/home/heliang05/liuyi/sre.full/sre16_eval_test/trials
export sre16_trials_tgl=/home/heliang05/liuyi/sre.full/sre16_eval_test/trials_tgl
export sre16_trials_yue=/home/heliang05/liuyi/sre.full/sre16_eval_test/trials_yue

rirs_noises=/mnt/lv10/person/liuyi/ly_database/RIRS_NOISES/
musan=/mnt/lv10/person/liuyi/ly_database/musan/

# The kaldi sre egs directory
kaldi_sre=/home/heliang05/liuyi/software/kaldi_gpu/egs/sre16

stage=-1

if [ $stage -le -1 ]; then
    # link the directories
    rm -fr utils steps sid conf local nnet
    ln -s $kaldi_sre/v2/utils ./
    ln -s $kaldi_sre/v2/steps ./
    ln -s $kaldi_sre/v2/sid ./
    ln -s $kaldi_sre/v2/conf ./
    ln -s $kaldi_sre/v2/local ./
    ln -s ../../voxceleb/v1/nnet ./
    exit 1
fi

## Data preparation
if [ $stage -le 0 ]; then
#   # Prepare Mixer6
#   local/make_mx6.sh /mnt/lv10/person/liuyi/ly_database $data

  # combine all sre data (04-08) and Mixer6
  utils/combine_data.sh $data/sre \
      $data_root/sre2004 $data_root/sre2005_train $data_root/sre2005_test \
      $data_root/sre2006_train $data_root/sre2006_test $data_root/sre08
  utils/validate_data_dir.sh --no-text --no-feats $data/sre
  utils/fix_data_dir.sh $data/sre

  # combine all swbd data.
  utils/combine_data.sh $data/swbd \
      $data_root/swbd2_phase1_train $data_root/swbd2_phase2_train $data_root/swbd2_phase3_train \
      $data_root/swbd_cellular1_train $data_root/swbd_cellular2_train
  utils/validate_data_dir.sh --no-text --no-feats $data/swbd
  utils/fix_data_dir.sh $data/swbd

  # prepare unlabeled Cantonese and Tagalog development data.
  # prepare sre16 evaluation data.
  rm -rf $data/sre16_major && cp -r $data_root/sre16_major $data/sre16_major
  rm -rf $data/sre16_minor && cp -r $data_root/sre16_minor $data/sre16_minor
  rm -rf $data/sre16_eval_enroll && cp -r $data_root/sre16_eval_enroll $data/sre16_eval_enroll
  rm -rf $data/sre16_eval_test && cp -r $data_root/sre16_eval_test $data/sre16_eval_test

  # prepare sre10 evaluation data.
  rm -rf $data/sre10_enroll_coreext_c5_$gender && cp -r $sre10_train_c5_ext $data/sre10_enroll_coreext_c5_$gender
  rm -rf $data/sre10_test_coreext_c5_$gender && cp -r $sre10_trials_c5_ext $data/sre10_test_coreext_c5_$gender
  rm -rf $data/sre10_enroll_10s_$gender && cp -r $sre10_train_10s $data/sre10_enroll_10s_$gender
  rm -rf $data/sre10_test_10s_$gender && cp -r $sre10_trials_10s $data/sre10_test_10s_$gender
fi

if [ $stage -le 1 ]; then
  # Make filterbanks and compute the energy-based VAD for each dataset
  for name in sre swbd sre10_enroll_coreext_c5_$gender sre10_test_coreext_c5_$gender sre10_enroll_10s_$gender sre10_test_10s_$gender; do
    steps/make_mfcc.sh --write-utt2num-frames true --mfcc-config conf/mfcc.conf --nj $fea_nj --cmd "$train_cmd" \
      $data/$name $exp/make_mfcc $mfccdir
    utils/fix_data_dir.sh $data/$name
    sid/compute_vad_decision.sh --nj $fea_nj --cmd "$train_cmd" \
      $data/$name $exp/make_vad $vaddir
    utils/fix_data_dir.sh $data/$name
  done

  for name in sre16_major sre16_minor sre16_eval_enroll sre16_eval_test; do
    steps/make_mfcc.sh --write-utt2num-frames true --mfcc-config conf/mfcc.conf --nj $fea_nj --cmd "$train_cmd" \
      $data/$name $exp/make_mfcc $mfccdir
    utils/fix_data_dir.sh $data/$name
    sid/compute_vad_decision.sh --nj $fea_nj --cmd "$train_cmd" \
      $data/$name $exp/make_vad $vaddir
    utils/fix_data_dir.sh $data/$name
  done

  utils/combine_data.sh --extra-files "utt2num_frames" $data/swbd_sre $data/swbd $data/sre
  utils/fix_data_dir.sh $data/swbd_sre
fi

if [ $stage -le 2 ]; then
  frame_shift=0.01
  awk -v frame_shift=$frame_shift '{print $1, $2*frame_shift;}' $data/swbd_sre/utt2num_frames > $data/swbd_sre/reco2dur

  # Make a version with reverberated speech
  rvb_opts=()
  rvb_opts+=(--rir-set-parameters "0.5, $rirs_noises/simulated_rirs/smallroom/rir_list")
  rvb_opts+=(--rir-set-parameters "0.5, $rirs_noises/simulated_rirs/mediumroom/rir_list")

  # Make a reverberated version of the SWBD+SRE list.  Note that we don't add any
  # additive noise here.
  python steps/data/reverberate_data_dir.py \
    "${rvb_opts[@]}" \
    --speech-rvb-probability 1 \
    --pointsource-noise-addition-probability 0 \
    --isotropic-noise-addition-probability 0 \
    --num-replications 1 \
    --source-sampling-rate 8000 \
    $data/swbd_sre $data/swbd_sre_reverb
  cp $data/swbd_sre/vad.scp $data/swbd_sre_reverb/
  utils/copy_data_dir.sh --utt-suffix "-reverb" $data/swbd_sre_reverb $data/swbd_sre_reverb.new
  rm -rf $data/swbd_sre_reverb
  mv $data/swbd_sre_reverb.new $data/swbd_sre_reverb

  # Prepare the MUSAN corpus, which consists of music, speech, and noise
  # suitable for augmentation.
  local/make_musan.sh $musan $data

  # Get the duration of the MUSAN recordings.  This will be used by the
  # script augment_data_dir.py.
  for name in speech noise music; do
    utils/data/get_utt2dur.sh $data/musan_${name}
    mv $data/musan_${name}/utt2dur $data/musan_${name}/reco2dur
  done

  # Augment with musan_noise
  python steps/data/augment_data_dir_new.py --utt-suffix "noise" --fg-interval 1 --fg-snrs "15:10:5:0" --fg-noise-dir "$data/musan_noise" $data/swbd_sre $data/swbd_sre_noise
  # Augment with musan_music
  python steps/data/augment_data_dir_new.py --utt-suffix "music" --bg-snrs "15:10:8:5" --num-bg-noises "1" --bg-noise-dir "$data/musan_music" $data/swbd_sre $data/swbd_sre_music
  # Augment with musan_speech
  python steps/data/augment_data_dir_new.py --utt-suffix "babble" --bg-snrs "20:17:15:13" --num-bg-noises "3:4:5:6:7" --bg-noise-dir "$data/musan_speech" $data/swbd_sre $data/swbd_sre_babble

  # Combine reverb, noise, music, and babble into one directory.
  utils/combine_data.sh $data/swbd_sre_aug $data/swbd_sre_reverb $data/swbd_sre_noise $data/swbd_sre_music $data/swbd_sre_babble

  utils/subset_data_dir.sh $data/swbd_sre_aug 128000 $data/swbd_sre_aug_128k
  utils/filter_scp.pl $data/swbd_sre_aug_128k/utt2spk $data/swbd_sre_aug/utt2uniq > $data/swbd_sre_aug_128k/utt2uniq
  utils/fix_data_dir.sh $data/swbd_sre_aug_128k

  # Make filterbanks for the augmented data.  Note that we do not compute a new
  # vad.scp file here.  Instead, we use the vad.scp from the clean version of
  # the list.
  steps/make_mfcc.sh --mfcc-config conf/mfcc.conf --nj $fea_nj --cmd "$train_cmd" \
    $data/swbd_sre_aug_128k $exp/make_mfcc $mfccdir

  # Combine the clean and augmented SWBD+SRE list.  This is now roughly
  # double the size of the original clean list.
  utils/combine_data.sh $data/swbd_sre_combined $data/swbd_sre_aug_128k $data/swbd_sre
  utils/fix_data_dir.sh $data/swbd_sre_combined

  # Filter out the clean + augmented portion of the SRE list.  This will be used to
  # train the PLDA model later in the script.
  # Just use SRE data for PLDA training
  utils/copy_data_dir.sh $data/swbd_sre_combined $data/sre_combined
  utils/filter_scp.pl $data/sre/spk2utt $data/swbd_sre_combined/spk2utt | utils/spk2utt_to_utt2spk.pl > $data/sre_combined/utt2spk
  utils/fix_data_dir.sh $data/sre_combined
fi

if [ $stage -le 3 ]; then
  local/nnet3/xvector/prepare_feats_for_egs.sh --nj $fea_nj --cmd "$train_cmd" \
    $data/swbd_sre_combined $data/swbd_sre_combined_nosil $exp/swbd_sre_combined_nosil
  utils/fix_data_dir.sh $data/swbd_sre_combined_nosil
fi

if [ $stage -le 4 ]; then
  # Now, we need to remove features that are too short after removing silence
  # frames.  We want at least 5s (500 frames) per utterance.
  min_len=500
  mv $data/swbd_sre_combined_nosil/utt2num_frames $data/swbd_sre_combined_nosil/utt2num_frames.bak
  awk -v min_len=${min_len} '$2 > min_len {print $1, $2}' $data/swbd_sre_combined_nosil/utt2num_frames.bak > $data/swbd_sre_combined_nosil/utt2num_frames
  utils/filter_scp.pl $data/swbd_sre_combined_nosil/utt2num_frames $data/swbd_sre_combined_nosil/utt2spk > $data/swbd_sre_combined_nosil/utt2spk.new
  mv $data/swbd_sre_combined_nosil/utt2spk.new $data/swbd_sre_combined_nosil/utt2spk
  utils/fix_data_dir.sh $data/swbd_sre_combined_nosil

  # We also want several utterances per speaker. Now we'll throw out speakers
  # with fewer than 8 utterances.
  min_num_utts=8
  awk '{print $1, NF-1}' $data/swbd_sre_combined_nosil/spk2utt > $data/swbd_sre_combined_nosil/spk2num
  awk -v min_num_utts=${min_num_utts} '$2 >= min_num_utts {print $1, $2}' $data/swbd_sre_combined_nosil/spk2num | utils/filter_scp.pl - $data/swbd_sre_combined_nosil/spk2utt > $data/swbd_sre_combined_nosil/spk2utt.new
  mv $data/swbd_sre_combined_nosil/spk2utt.new $data/swbd_sre_combined_nosil/spk2utt
  utils/spk2utt_to_utt2spk.pl $data/swbd_sre_combined_nosil/spk2utt > $data/swbd_sre_combined_nosil/utt2spk

  utils/filter_scp.pl $data/swbd_sre_combined_nosil/utt2spk $data/swbd_sre_combined_nosil/utt2num_frames > $data/swbd_sre_combined_nosil/utt2num_frames.new
  mv $data/swbd_sre_combined_nosil/utt2num_frames.new $data/swbd_sre_combined_nosil/utt2num_frames

  # Now we're ready to create training examples.
  utils/fix_data_dir.sh $data/swbd_sre_combined_nosil
fi

if [ $stage -le 5 ]; then
  # Split the validation set
  mkdir -p $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train

  num_heldout_spk=128
  num_heldout_utts_per_spk=5

  # The augmented data is similar with the not-augmented one. If an augmented version is in the valid set, it should not appear in the training data.
  # We first remove the augmented data and only sample from the original version
  sed 's/-noise//' $data/swbd_sre_combined_nosil/utt2spk | sed 's/-music//' | sed 's/-babble//' | sed 's/-reverb//' |\
    paste -d ' ' $data/swbd_sre_combined_nosil/utt2spk - | cut -d ' ' -f 1,3 > $data/swbd_sre_combined_nosil/utt2uniq
  utils/utt2spk_to_spk2utt.pl $data/swbd_sre_combined_nosil/utt2uniq > $data/swbd_sre_combined_nosil/uniq2utt
  cat $data/swbd_sre_combined_nosil/utt2spk | utils/apply_map.pl -f 1 $data/swbd_sre_combined_nosil/utt2uniq |\
    sort | uniq > $data/swbd_sre_combined_nosil/utt2spk.uniq
  utils/utt2spk_to_spk2utt.pl $data/swbd_sre_combined_nosil/utt2spk.uniq > $data/swbd_sre_combined_nosil/spk2utt.uniq
  python utils/sample_validset_spk2utt.py $num_heldout_spk $num_heldout_utts_per_spk $data/swbd_sre_combined_nosil/spk2utt.uniq > $data/swbd_sre_combined_nosil/valid/spk2utt.uniq

  # Then we find all the data that is augmented from the original version.
  cat $data/swbd_sre_combined_nosil/valid/spk2utt.uniq | utils/apply_map.pl -f 2- $data/swbd_sre_combined_nosil/uniq2utt > $data/swbd_sre_combined_nosil/valid/spk2utt
  utils/spk2utt_to_utt2spk.pl $data/swbd_sre_combined_nosil/valid/spk2utt > $data/swbd_sre_combined_nosil/valid/utt2spk
  cp $data/swbd_sre_combined_nosil/feats.scp $data/swbd_sre_combined_nosil/valid
  utils/filter_scp.pl $data/swbd_sre_combined_nosil/valid/utt2spk $data/swbd_sre_combined_nosil/utt2num_frames > $data/swbd_sre_combined_nosil/valid/utt2num_frames
  utils/fix_data_dir.sh $data/swbd_sre_combined_nosil/valid

  utils/filter_scp.pl --exclude $data/swbd_sre_combined_nosil/valid/utt2spk $data/swbd_sre_combined_nosil/utt2spk > $data/swbd_sre_combined_nosil/train/utt2spk
  utils/utt2spk_to_spk2utt.pl $data/swbd_sre_combined_nosil/train/utt2spk > $data/swbd_sre_combined_nosil/train/spk2utt
  cp $data/swbd_sre_combined_nosil/feats.scp $data/swbd_sre_combined_nosil/train
  utils/filter_scp.pl $data/swbd_sre_combined_nosil/train/utt2spk $data/swbd_sre_combined_nosil/utt2num_frames > $data/swbd_sre_combined_nosil/train/utt2num_frames
  utils/fix_data_dir.sh $data/swbd_sre_combined_nosil/train

  # In the training, we need an additional file `spklist` to map the speakers to the indices.
  awk -v id=0 '{print $1, id++}' $data/swbd_sre_combined_nosil/train/spk2utt > $data/swbd_sre_combined_nosil/train/spklist
fi

if [ $stage -le 6 ]; then
#  # Training a softmax network
#  nnetdir=$exp/xvector_nnet_tdnn_softmax_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_softmax_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#
#  # Train asoftmax network
#  nnetdir=$exp/xvector_nnet_tdnn_asoftmax_m1_linear_bn
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_asoftmax_m1_linear_bn.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#  nnetdir=$exp/xvector_nnet_tdnn_asoftmax_m2_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_asoftmax_m2_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#  nnetdir=$exp/xvector_nnet_tdnn_asoftmax_m4_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_asoftmax_m4_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#
#  # AMSoftmax
#  nnetdir=$exp/xvector_nnet_tdnn_amsoftmax_m0.10_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_amsoftmax_m0.10_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#  nnetdir=$exp/xvector_nnet_tdnn_amsoftmax_m0.15_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_amsoftmax_m0.15_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#  nnetdir=$exp/xvector_nnet_tdnn_amsoftmax_m0.20_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_amsoftmax_m0.20_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#  nnetdir=$exp/xvector_nnet_tdnn_amsoftmax_m0.25_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_amsoftmax_m0.25_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#  nnetdir=$exp/xvector_nnet_tdnn_amsoftmax_m0.30_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_amsoftmax_m0.30_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#  nnetdir=$exp/xvector_nnet_tdnn_amsoftmax_m0.35_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_amsoftmax_m0.35_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir

#  # ArcSoftmax
#  nnetdir=$exp/xvector_nnet_tdnn_arcsoftmax_m0.10_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_arcsoftmax_m0.10_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir

#  nnetdir=$exp/xvector_nnet_tdnn_arcsoftmax_m0.15_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_arcsoftmax_m0.15_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir

#  nnetdir=$exp/xvector_nnet_tdnn_arcsoftmax_m0.20_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_arcsoftmax_m0.20_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir
#
#  nnetdir=$exp/xvector_nnet_tdnn_arcsoftmax_m0.25_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_arcsoftmax_m0.25_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir

#  nnetdir=$exp/xvector_nnet_tdnn_arcsoftmax_m0.30_linear_bn_1e-2
#  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_arcsoftmax_m0.30_linear_bn_1e-2.json \
#    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
#    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
#    $nnetdir

  nnetdir=$exp/xvector_nnet_tdnn_arcsoftmax_m0.35_linear_bn_1e-2
  nnet/run_train_nnet.sh --cmd "$cuda_cmd" --env tf_gpu --continue-training false nnet_conf/tdnn_arcsoftmax_m0.35_linear_bn_1e-2.json \
    $data/swbd_sre_combined_nosil/train $data/swbd_sre_combined_nosil/train/spklist \
    $data/swbd_sre_combined_nosil/valid $data/swbd_sre_combined_nosil/train/spklist \
    $nnetdir

exit 1
fi

nnetdir=$exp/xvector_nnet_tdnn_softmax_1e-2
checkpoint='last'

if [ $stage -le 7 ];then
  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "tdnn6_dense" \
    $nnetdir $data/sre_combined $nnetdir/xvectors_sre_combined

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "tdnn6_dense" \
    $nnetdir $data/sre10_enroll_coreext_c5_$gender $nnetdir/xvectors_sre10_enroll_coreext_c5_$gender

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "tdnn6_dense" \
    $nnetdir $data/sre10_test_coreext_c5_$gender $nnetdir/xvectors_sre10_test_coreext_c5_$gender

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "tdnn6_dense" \
    $nnetdir $data/sre10_enroll_10s_$gender $nnetdir/xvectors_sre10_enroll_10s_$gender

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "tdnn6_dense" \
    $nnetdir $data/sre10_test_10s_$gender $nnetdir/xvectors_sre10_test_10s_$gender
fi

# PLDA scoring on NIST SRE 2010
if [ $stage -le 8 ]; then
  ### !!! Re-train LDA and PLDA models when it is referred again
  lda_dim=150

  $train_cmd $nnetdir/xvectors_sre_combined/log/compute_mean.log \
    ivector-mean scp:$nnetdir/xvectors_sre_combined/xvector.scp \
    $nnetdir/xvectors_sre_combined/mean.vec || exit 1;

  # This script uses LDA to decrease the dimensionality prior to PLDA.
  $train_cmd $nnetdir/xvectors_sre_combined/log/lda.log \
    ivector-compute-lda --total-covariance-factor=0.0 --dim=$lda_dim \
    "ark:ivector-subtract-global-mean scp:$nnetdir/xvectors_sre_combined/xvector.scp ark:- |" \
    ark:$data/sre_combined/utt2spk $nnetdir/xvectors_sre_combined/transform.mat || exit 1;

  $train_cmd $nnetdir/xvectors_sre_combined/log/plda_lda${lda_dim}.log \
    ivector-compute-plda ark:$data/sre_combined/spk2utt \
    "ark:ivector-subtract-global-mean scp:$nnetdir/xvectors_sre_combined/xvector.scp ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:-  ark:- |" \
    $nnetdir/xvectors_sre_combined/plda_lda${lda_dim} || exit 1;

  # Coreext C5
  $train_cmd $nnetdir/xvector_scores/log/sre10_coreext_c5_$gender.log \
    ivector-plda-scoring --normalize-length=true \
    --num-utts=ark:$nnetdir/xvectors_sre10_enroll_coreext_c5_$gender/num_utts.ark \
    "ivector-copy-plda --smoothing=0.0 $nnetdir/xvectors_sre_combined/plda_lda${lda_dim} - |" \
    "ark:ivector-mean ark:$data/sre10_enroll_coreext_c5_$gender/spk2utt scp:$nnetdir/xvectors_sre10_enroll_coreext_c5_$gender/xvector.scp ark:- | ivector-subtract-global-mean $nnetdir/xvectors_sre_combined/mean.vec ark:- ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:- ark:- |" \
    "ark:ivector-subtract-global-mean $nnetdir/xvectors_sre_combined/mean.vec scp:$nnetdir/xvectors_sre10_test_coreext_c5_$gender/xvector.scp ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:- ark:- |" \
    "cat '$data/sre10_test_coreext_c5_$gender/trials' | cut -d\  --fields=1,2 |" $nnetdir/xvector_scores/sre10_coreext_c5_scores_$gender || exit 1;

  # 10s-10s
  $train_cmd $nnetdir/xvector_scores/log/sre10_10s_$gender.log \
    ivector-plda-scoring --normalize-length=true \
    --num-utts=ark:$nnetdir/xvectors_sre10_enroll_10s_$gender/num_utts.ark \
    "ivector-copy-plda --smoothing=0.0 $nnetdir/xvectors_sre_combined/plda_lda${lda_dim} - |" \
    "ark:ivector-mean ark:$data/sre10_enroll_10s_$gender/spk2utt scp:$nnetdir/xvectors_sre10_enroll_10s_$gender/xvector.scp ark:- | ivector-subtract-global-mean $nnetdir/xvectors_sre_combined/mean.vec ark:- ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:- ark:- |" \
    "ark:ivector-subtract-global-mean $nnetdir/xvectors_sre_combined/mean.vec scp:$nnetdir/xvectors_sre10_test_10s_$gender/xvector.scp ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:- ark:- |" \
    "cat '$data/sre10_test_10s_$gender/trials' | cut -d\  --fields=1,2 |" $nnetdir/xvector_scores/sre10_10s_scores_$gender || exit 1;

  eval_plda_sre10.sh $gender $data $nnetdir
fi

if [ $stage -le 9 ]; then
  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "tdnn6_dense" \
    $nnetdir $data/sre16_major $nnetdir/xvectors_sre16_major

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "tdnn6_dense" \
    $nnetdir $data/sre16_eval_enroll $nnetdir/xvectors_sre16_eval_enroll

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "tdnn6_dense" \
    $nnetdir $data/sre16_eval_test $nnetdir/xvectors_sre16_eval_test
fi

# PLDA scoring on SRE 2016
if [ $stage -le 10 ]; then
  ### !!! Re-train LDA and PLDA models when it is referred again
  lda_dim=150

  $train_cmd $nnetdir/xvectors_sre16_major/log/compute_mean.log \
    ivector-mean scp:$nnetdir/xvectors_sre16_major/xvector.scp \
    $nnetdir/xvectors_sre16_major/mean.vec || exit 1;

  # This script uses LDA to decrease the dimensionality prior to PLDA.
  $train_cmd $nnetdir/xvectors_sre_combined/log/lda.log \
    ivector-compute-lda --total-covariance-factor=0.0 --dim=$lda_dim \
    "ark:ivector-subtract-global-mean scp:$nnetdir/xvectors_sre_combined/xvector.scp ark:- |" \
    ark:$data/sre_combined/utt2spk $nnetdir/xvectors_sre_combined/transform.mat || exit 1;

  # Train an out-of-domain PLDA model.
  $train_cmd $nnetdir/xvectors_sre_combined/log/plda_lda${lda_dim}.log \
    ivector-compute-plda ark:$data/sre_combined/spk2utt \
    "ark:ivector-subtract-global-mean scp:$nnetdir/xvectors_sre_combined/xvector.scp ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:-  ark:- |" \
    $nnetdir/xvectors_sre_combined/plda_lda${lda_dim} || exit 1;

  # Here we adapt the out-of-domain PLDA model to SRE16 major, a pile
  # of unlabeled in-domain data.  In the future, we will include a clustering
  # based approach for domain adaptation, which tends to work better.
  $train_cmd $nnetdir/xvectors_sre16_major/log/plda_lda${lda_dim}_sre16_adapt.log \
    ivector-adapt-plda --within-covar-scale=0.75 --between-covar-scale=0.25 \
    $nnetdir/xvectors_sre_combined/plda_lda${lda_dim} \
    "ark:ivector-subtract-global-mean scp:$nnetdir/xvectors_sre16_major/xvector.scp ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:- ark:- |" \
    $nnetdir/xvectors_sre16_major/plda_lda${lda_dim}_sre16_adapt || exit 1;

  # Get results using the out-of-domain PLDA model.
  $train_cmd $nnetdir/xvector_scores/log/sre16_eval.log \
    ivector-plda-scoring --normalize-length=true \
    --num-utts=ark:$nnetdir/xvectors_sre16_eval_enroll/num_utts.ark \
    "ivector-copy-plda --smoothing=0.0 $nnetdir/xvectors_sre_combined/plda_lda${lda_dim} - |" \
    "ark:ivector-mean ark:$data/sre16_eval_enroll/spk2utt scp:$nnetdir/xvectors_sre16_eval_enroll/xvector.scp ark:- | ivector-subtract-global-mean $nnetdir/xvectors_sre16_major/mean.vec ark:- ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:- ark:- |" \
    "ark:ivector-subtract-global-mean $nnetdir/xvectors_sre16_major/mean.vec scp:$nnetdir/xvectors_sre16_eval_test/xvector.scp ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:- ark:- |" \
    "cat '$sre16_trials' | cut -d\  --fields=1,2 |" $nnetdir/xvector_scores/sre16_eval_scores || exit 1;

  # Get results using the adapted PLDA model.
  $train_cmd $nnetdir/xvector_scores/log/sre16_eval_scoring_adapt.log \
    ivector-plda-scoring --normalize-length=true \
    --num-utts=ark:$nnetdir/xvectors_sre16_eval_enroll/num_utts.ark \
    "ivector-copy-plda --smoothing=0.0 $nnetdir/xvectors_sre16_major/plda_lda${lda_dim}_sre16_adapt - |" \
    "ark:ivector-mean ark:$data/sre16_eval_enroll/spk2utt scp:$nnetdir/xvectors_sre16_eval_enroll/xvector.scp ark:- | ivector-subtract-global-mean $nnetdir/xvectors_sre16_major/mean.vec ark:- ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:- ark:- |" \
    "ark:ivector-subtract-global-mean $nnetdir/xvectors_sre16_major/mean.vec scp:$nnetdir/xvectors_sre16_eval_test/xvector.scp ark:- | transform-vec $nnetdir/xvectors_sre_combined/transform.mat ark:- ark:- | ivector-normalize-length ark:- ark:- |" \
    "cat '$sre16_trials' | cut -d\  --fields=1,2 |" $nnetdir/xvector_scores/sre16_eval_scores_adapt || exit 1;

  eval_plda_sre16.sh $gender $data $nnetdir
  exit 1
fi

nnetdir=$exp/xvector_nnet_tdnn_softmax_1e-2
checkpoint='last'

if [ $stage -le 11 ];then
  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "output" \
    $nnetdir $data/sre10_enroll_coreext_c5_$gender $nnetdir/xvectors_sre10_enroll_coreext_c5_$gender

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "output" \
    $nnetdir $data/sre10_test_coreext_c5_$gender $nnetdir/xvectors_sre10_test_coreext_c5_$gender

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "output" \
    $nnetdir $data/sre10_enroll_10s_$gender $nnetdir/xvectors_sre10_enroll_10s_$gender

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "output" \
    $nnetdir $data/sre10_test_10s_$gender $nnetdir/xvectors_sre10_test_10s_$gender

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "output" \
    $nnetdir $data/sre16_eval_enroll $nnetdir/xvectors_sre16_eval_enroll

  nnet/run_extract_embeddings.sh --cmd "$train_cmd" --nj $nnet_nj --use-gpu false --checkpoint $checkpoint --stage 0 \
    --chunk-size 10000 --normalize false --node "output" \
    $nnetdir $data/sre16_eval_test $nnetdir/xvectors_sre16_eval_test
fi

if [ $stage -le 12 ]; then
  mkdir -p $nnetdir/xvector_scores

  # Coreext C5
  cat $data/sre10_test_coreext_c5_$gender/trials | awk '{print $1, $2}' | \
    ivector-compute-dot-products - \
      "ark:ivector-mean ark:$data/sre10_enroll_coreext_c5_$gender/spk2utt scp:$nnetdir/xvectors_sre10_enroll_coreext_c5_$gender/xvector.scp ark:- | ivector-normalize-length ark:- ark:- |" \
      "ark:ivector-normalize-length scp:$nnetdir/xvectors_sre10_test_coreext_c5_$gender/xvector.scp ark:- |" \
      $nnetdir/xvector_scores/sre10_coreext_c5_scores_$gender.cos

  # 10s-10s
  cat $data/sre10_test_10s_$gender/trials | awk '{print $1, $2}' | \
    ivector-compute-dot-products - \
      "ark:ivector-mean ark:$data/sre10_enroll_10s_$gender/spk2utt scp:$nnetdir/xvectors_sre10_enroll_10s_$gender/xvector.scp ark:- | ivector-normalize-length ark:- ark:- |" \
      "ark:ivector-normalize-length scp:$nnetdir/xvectors_sre10_test_10s_$gender/xvector.scp ark:- |" \
      $nnetdir/xvector_scores/sre10_10s_scores_$gender.cos

  # SRE2016
  cat $sre16_trials | awk '{print $1, $2}' | \
    ivector-compute-dot-products - \
      "ark:ivector-mean ark:$data/sre16_eval_enroll/spk2utt scp:$nnetdir/xvectors_sre16_eval_enroll/xvector.scp ark:- | ivector-normalize-length ark:- ark:- |" \
      "ark:ivector-normalize-length scp:$nnetdir/xvectors_sre16_eval_test/xvector.scp ark:- |" \
      $nnetdir/xvector_scores/sre16_eval_scores.cos

  eval_cos.sh $gender $data $nnetdir
  exit 1
fi


#!/bin/bash

docker build . -t tmats/deepsdf:latest


<reponame>lukasz-bielinski/generate_blocklist
#!/bin/bash

while true; do
curl -s https://www.iblocklist.com/lists.json | \
    jq -r '.lists[] | select(.subscription == "false") | .list' | \
    awk '{ print "http://list.iblocklist.com/?fileformat=p2p&archiveformat=gz&list=" $0 }' | \
    xargs wget -O - | \
    gunzip | \
    egrep -v '^#' | \
    gzip > webserver-files/tmp.gz

    rm -f webserver-files/blocklist.gz || true
    cp webserver-files/tmp.gz webserver-files/blocklist.gz
    # serve extracted
    gunzip -f webserver-files/blocklist.gz

echo "sleep for 1800s"
    sleep 1800

done


<reponame>cau-placc/pakcs
GHC_VERSION=8.8.3

docker build \
    --build-arg GHC_VERSION=${GHC_VERSION} \
    -t pakcs-swi-ci:${GHC_VERSION} \
    -f ./Dockerfile-swi .


#!/usr/bin/env bash
set -euo pipefail
[ -n "$MAIL_DOMAIN" ]
exec opendkim-genkey \
  --bits=2048 \
  --directory=/keys \
  --domain="mail.$MAIL_DOMAIN" \
  --hash-algorithms=sha256 \
  --restrict \
  --selector=mail \
  "$@"


time gcc -o jx2vm.elf jx2vm.c -g -O2 -lm -DUSE_SDL -lSDL
# time clang -o jx2vm.elf jx2vm.c -g -O2 -lm -DUSE_SDL -lSDL


<filename>salt/appliance/postfix/prepare-postfix.sh<gh_stars>0
prepare_postfix () {
    local restart_opendkim=false
    # ### opendkim: rewrite opendkim.conf with APPPLIANCE_DOMAIN
    sed -i.bak  "s/^Domain.*/Domain                 $APPLIANCE_DOMAIN/" /etc/opendkim.conf
    if ! diff -q /etc/opendkim.conf.bak /etc/opendkim.conf; then
        echo "opendkim.conf changed"
        diff -u /etc/opendkim.conf.bak /etc/opendkim.conf
        restart_opendkim=true
    fi
    # ### opendkim: rewrite rsa key if not existing or different with APPLIANCE_DKIM_KEY
    if test ! -d /etc/dkimkeys; then mkdir /etc/dkimkeys; fi
    echo "$APPLIANCE_DKIM_KEY" > /etc/dkimkeys/dkim.key.new
    chown opendkim /etc/dkimkeys/dkim.key.new
    chmod "0600" /etc/dkimkeys/dkim.key.new
    if ! diff -q /etc/dkimkeys/dkim.key /etc/dkimkeys/dkim.key.new; then
        echo "/etc/dkimkeys/dkim.key changed"
        mv /etc/dkimkeys/dkim.key.new /etc/dkimkeys/dkim.key
        restart_opendkim=true
    fi
    if $restart_opendkim; then
        systemctl restart opendkim
    fi
    # ### postfix: rewrite postfix main.cf with APPLIANCE_DOMAIN, restart postfix (ssl keys change)
    sed -i.bak  "s/^myhostname.*/myhostname = $APPLIANCE_DOMAIN/;s/^mydomain.*/mydomain = $APPLIANCE_DOMAIN/" /etc/postfix/main.cf
    if ! diff -q /etc/postfix/main.cf /etc/postfix/main.cf.bak; then
        echo "postfix main.cf changed"
        diff -u /etc/postfix/main.cf.bak /etc/postfix/main.cf
    fi
    systemctl restart postfix
}


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

for file in $(find .foundations -type f -name "*.config"); do \
    envsubst < $file > $file.yaml
done


#!/bin/bash
"`dirname $0`/stop-server.sh"
"`dirname $0`/run-server.sh"


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

#
# install-valgrind.sh - installs valgrind for persistent memory
#

set -e

if [ "${SKIP_VALGRIND_BUILD}" ]; then
	echo "Variable 'SKIP_VALGRIND_BUILD' is set; skipping building valgrind (pmem's fork)"
	exit
fi

OS=$1

git clone https://github.com/pmem/valgrind.git
cd valgrind
# valgrind v3.15 with pmemcheck
git checkout c27a8a2f973414934e63f1e94bc84c0a580e3840

# set OS-specific configure options
OS_SPECIFIC=""
case $(echo $OS | cut -d'-' -f1) in
	centos|opensuse)
		OS_SPECIFIC="--libdir=/usr/lib64"
		;;
esac

./autogen.sh
./configure --prefix=/usr $OS_SPECIFIC
make -j$(nproc)
sudo make -j$(nproc) install
cd ..
rm -r valgrind


#!/bin/sh
# Copyright 2020 Huawei Technologies Co., Ltd.
#
# 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.

# validate name
validate_name() {
  hostname="$1"
  len="${#hostname}"
  if [ "${len}" -gt "64" ]; then
    return 1
  fi
  if ! echo "$hostname" | grep -qE '^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-]*[a-zA-Z0-9]$'; then
    return 1
  fi
  return 0
}

# validates whether file exist
validate_file_exists() {
  file_path="$1"

  # checks variable is unset
  if [ -z "$file_path" ]; then
    echo "file path variable is not set"
    return 1
  fi

  # checks if file exists
  if [ ! -f "$file_path" ]; then
    echo "file does not exist"
    return 1
  fi

  return 0
}

# Validates if dir exists
validate_dir_exists()
{
   dir_path="$1"

   # checks if dir path var is unset
   if [ -z "$dir_path" ] ; then
     echo "dir path variable is not set"
     return 1
   fi

   # checks if dir exists
   if [ ! -d "$dir_path" ] ; then
     echo "dir does not exist"
     return 1
   fi

   return 0
}

# Validates if ip is valid
validate_ip()
{
 ip_var="$1"
    # checks if variable is unset
 if [ -z "$ip_var" ] ; then
    echo "ip is not set"
    return 1
 fi

 if ! echo "$ip_var" | grep -qE '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.)' ; then
   return 1
 fi
 return 0
}

# Contain at most 63 characters
# Contain only lowercase alphanumeric characters or '-'
# Start with an alphanumeric character
# End with an alphanumeric character
validate_host_name()
{
 hostname="$1"
 len="${#hostname}"
 if [ "${len}" -gt "253" ] ; then
   return 1
 fi
 if ! echo "$hostname" | grep -qE '^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$' ; then
   return 1
 fi
 return 0
}

# Validating if port is > 1 and < 65535 , not validating reserved port.
validate_port_num()
{
 portnum="$1"
 len="${#portnum}"
 if [ "${len}" -gt "5" ] ; then
   return 1
 fi
 if ! echo "$portnum" | grep -qE '^-?[0-9]+$' ; then
   return 1
 fi
 if [ "$portnum" -gt "65535" ] || [ "$portnum" -lt "1" ] ; then
   return 1
 fi
 return 0
}

# ssl parameters validation
validate_file_exists "/usr/app/ssl/server_tls.crt"
valid_server_certificate="$?"
if [ ! "$valid_server_certificate" -eq "0" ]; then
  echo "server certificate is missing"
  exit 1
fi

validate_file_exists "/usr/app/ssl/server_tls.key"
valid_server_certificate="$?"
if [ ! "$valid_server_certificate" -eq "0" ]; then
  echo "server key is missing"
  exit 1
fi

validate_file_exists "/usr/app/ssl/ca.crt"
valid_server_certificate="$?"
if [ ! "$valid_server_certificate" -eq "0" ]; then
  echo "ca cert is missing"
  exit 1
fi

if [ ! -z "$LOG_DIR" ] ; then
  validate_dir_exists "$LOG_DIR"
  valid_log_dir="$?"
  if [ ! "$valid_log_dir" -eq "0" ] ; then
    echo "log directory does not exist"
    exit 1
  fi
fi

validate_ip "$LISTEN_IP"
valid_listen_ip="$?"
if [ ! "$valid_listen_ip" -eq "0" ]; then
  echo "invalid ip address for listen ip"
  exit 1
fi

# app parameters validation
if [ ! -z "$MEP_SERVER_ADDR" ] ; then
  validate_host_name "$MEP_SERVER_ADDR"
  valid_mep_host_name="$?"
  if [ ! "$valid_mep_host_name" -eq "0" ] ; then
     echo "invalid mep host name"
     exit 1
  fi
fi

if [ ! -z "$MEP_SERVER_PORT" ] ; then
  validate_port_num "$MEP_SERVER_PORT"
  valid_mep_port="$?"
  if [ ! "$valid_mep_port" -eq "0" ] ; then
     echo "invalid mep port number"
     exit 1
  fi
fi

# db parameters validation
if [ ! -z "$APPRULEMGR_DB" ]; then
  validate_name "$APPRULEMGR_DB"
  valid_name="$?"
  if [ ! "$valid_name" -eq "0" ]; then
    echo "invalid DB name"
    exit 1
  fi
else
  export APPRULEMGR_DB=apprulemgrdb
fi

# db parameters validation
if [ ! -z "$APPRULEMGR_USER" ]; then
  validate_name "$APPRULEMGR_USER"
  valid_name="$?"
  if [ ! "$valid_name" -eq "0" ]; then
    echo "invalid DB user name"
    exit 1
  fi
else
  export APPRULEMGR_USER=apprulemgr
fi

if [ ! -z "$APPRULEMGR_DB_HOST" ]; then
  validate_host_name "$APPRULEMGR_DB_HOST"
  valid_db_host_name="$?"
  if [ ! "$valid_db_host_name" -eq "0" ]; then
    echo "invalid db host name"
    exit 1
  fi
else
  export APPRULEMGR_DB_HOST=mepm-postgres
fi

if [ ! -z "$APPRULEMGR_DB_PORT" ]; then
  validate_port_num "$APPRULEMGR_DB_PORT"
  valid_db_port="$?"
  if [ ! "$valid_db_port" -eq "0" ]; then
    echo "invalid apprulemgr db port number"
    exit 1
  fi
else
  export APPRULEMGR_DB_PORT=5432
fi

sed -i "s/^HTTPSAddr.*=.*$/HTTPSAddr = $(hostname -i)/g" conf/app.conf
sed -i "s/^dbAdapter.*=.*$/dbAdapter = ${APPRULEMGR_DB_ADAPTER}/g" conf/app.conf
sed -i "s/^isHTTPS.*=.*$/isHTTPS = $(IS_HTTPS)/g" conf/app.conf

cd /usr/app
umask 0027
$HOME/bin/apprulemgr


#!/bin/sh

branch=$(git rev-parse --abbrev-ref HEAD)

if [ $branch != "main" ]
then
    echo "Needs to be on main branch to bump current version"
    exit 1
fi


<filename>Scripts/script_debs.sh<gh_stars>1-10
#!/usr/bin/env bash
# autor: HenriqueAD <www.osistematico.com.br> <youtube.com/OSistematico>
# descrição: Efetua o download e instala pacotees DEB.
# version: 1.0
# licença: MIT License

# ---------- CORES PARA MELHOR VISUALIZAÇÃO ---------- #

export corGreen="\033[1;32m" #Instalação VERDE
export corBlue="\033[1;34m" #Atualização AZUL
export corRed="\033[1;31m" #Remoção VERMELHO
export corGrey="\033[40;1;37m" #CINZA
export corYellow="\033[1;33m" #AMARELO

# ---------- PARAMETRO PASSADO DE script_menu ---------- #
senha="$1"

# ---------- VARIÁVEIS DE AMBIENTE DEBS ---------- #

GOOGLE_CHROME="google-chrome-stable_current_amd64.deb"
APP_4K_VIDEO_DOWNLOADER="4kvideodownloader_4.12.1-1_amd64.deb"
APP_4K_YOUTUBE_TOMP3="4kyoutubetomp3_3.12.0-1_amd64.deb"
SIMPLE_NOTE="Simplenote-linux-1.15.1-amd64.deb"
OPENCOMIC="v0.1.5/opencomic_0.1.5_amd64.deb"
XNCONVERT="XnConvert-linux-x64.deb"

URL_GOOGLE_CHROME="https://dl.google.com/linux/direct/$GOOGLE_CHROME"
URL_4K_VIDEO_DOWNLOADER="https://dl.4kdownload.com/app/$APP_4K_VIDEO_DOWNLOADER"
URL_4K_YOUTUBE_TOMP3="https://dl.4kdownload.com/app/$APP_4K_YOUTUBE_TOMP3"
URL_SIMPLE_NOTE="https://github.com/Automattic/simplenote-electron/releases/download/v1.15.1/$SIMPLE_NOTE"
URL_OPENCOMIC="https://github.com/ollm/OpenComic/releases/download/$OPENCOMIC"
URL_XNCONVERT="https://download.xnview.com/$XNCONVERT"

DIR_DOWNLOADS="$HOME/Downloads/Apps_DEB"

# ---------- DOWNLOAD DE PACOTES DEBS ---------- #
echo ""
echo -e $corYellow " --- Efetuando o download de pacotes DEBs --- \033[0m"
mkdir "$DIR_DOWNLOADS"
wget -c "$URL_GOOGLE_CHROME"       -P "$DIR_DOWNLOADS"
wget -c "$URL_SIMPLE_NOTE"         -P "$DIR_DOWNLOADS"
wget -c "$URL_4K_VIDEO_DOWNLOADER" -P "$DIR_DOWNLOADS"
wget -c "$URL_4K_YOUTUBE_TOMP3"    -P "$DIR_DOWNLOADS"
wget -c "$URL_OPENCOMIC"           -P "$DIR_DOWNLOADS"
wget -c "$URL_XNCONVERT"           -P "$DIR_DOWNLOADS"

# ----------- INSTALANDO PACOTES DEBS ----------- #
echo ""
echo -e $corGreen " --- Instalando pacotes DEBs --- \033[0m"
echo ${senha} | (sudo -S apt install $DIR_DOWNLOADS/*.deb -y)
echo ""
echo -e $corGreen " --- Pacotes DEBs instalados com sucesso! --- \033[0m"
echo ""


<reponame>Anorlondo448/copilot-cli
#! /bin/sh

[ -z "$STATUS" ] && STATUS="NOT OVERRIDDEN"

sleep 20

for i in 1 2 3 4 5 6 7 8; do
    echo "e2e environment variables: $STATUS"
    sleep 3
done


cd ~/code/call8/config

sudo cp broadcasting.php.do broadcasting.php

cd ~/code/call8/resources/js

sudo cp bootstrap.js.do bootstrap.js

docker exec -it node sh


#!/bin/bash

#shellcheck disable=SC2034
test_name="airgap_a1_migration"
test_container_name="a1-migration.test"
test_upgrade_strategy="none"
test_deploy_inspec_profiles=(a2-migrate-from-v1-integration)

# Note: this matches the hashes in a1stub/server.go,
#       $2a$12$SWA2q.A2Pe8PzNw.i7DcruoIoq.Lgvz0G7O07.V21I077PveSkGy6
#       and
#       $2a$12$DpdJVmcRKtz8LFB3cZ.QrOWA.3XrbW6htKrzKl1xT4Z/XLGgFR90y
export AUTOMATE_API_DEFAULT_PASSWORD="<PASSWORD>"
export A1_BUILDER_PASSWORD="<PASSWORD>"

do_build() {
    do_build_default
    set_test_manifest "build.json"
    log_info "Installing harts"
    # We need to make sure the harts are installed so that the bundle creation works
    #shellcheck disable=SC2154
    if ls "${test_hartifacts_path}"/*.hart
    then
        hab pkg install "${test_hartifacts_path}"/*.hart
    fi

    log_info "Creating airgap bundle"
    #shellcheck disable=SC2154
    chef-automate airgap bundle create \
        --manifest "${test_manifest_path}" \
        --hartifacts "${test_hartifacts_path}" \
        --override-origin "$HAB_ORIGIN" \
        bundle.aib

    sync_a1_migration_data

    # Installation of the artifact should create /hab
    rm -rf /hab
}

do_deploy() {
    #shellcheck disable=SC2154
    chef-automate migrate-from-v1 "$test_config_path" \
        --airgap-bundle bundle.aib \
        --admin-password <PASSWORD> \
        --skip-preflight \
        --self-test \
        --debug \
        --yes
}


<filename>alt.p8-postgresql/12/root/docker-cmd.sh
#!/bin/sh

function walg_conf_json() {
ifs=$IFS
json='{'
n=0
for name in $WALG_VARS
do
  if [ $n -gt 0 ]
  then
    sep=",\n\t"
  else
    sep="\n\t"
  fi
  eval value=\${$name}
#   re='^[0-9]+$'
#   if  [[ $value =~ $re ]] ; then
#     #echo "$value is number"
#     json="$json$sep\"$name\":$value"
#   else
    json="$json$sep\"$name\":\"$value\""
#   fi
#   echo $var=$value
  let n=$n+1
done
json="$json\n}\n"
echo  $json
}

set -x

if [ -z "$POSTGRES_logging_collector" ]; then POSTGRES_logging_collector=on; fi
if [ -z "$POSTGRES_log_directory" ]; then POSTGRES_log_directory=pg_log; fi
if [ -z "$POSTGRES_log_filename" ]; then POSTGRES_log_filename=\'postgresql-%u_%H.log\'; fi
if [ -z "$POSTGRES_log_rotation_age" ]; then POSTGRES_log_rotation_age=1h ;fi
if [ -z "$POSTGRES_log_rotation_size" ]; then POSTGRES_log_rotation_size=0; fi

for confVar in `echo ${!POSTGRES*}`
do
  confValue=${!confVar}
  key=${confVar:9}
  if [ "$confValue" ]
  then
    sedExp="$sedExp -e s|#$key.*=.*|$key.*=.*| -e s|^$key.*=.*|$key=$confValue|"
  fi
done
#echo "$sedExp"
ErrFile=/tmp/sed.log
ConfFile=/var/lib/pgsql/data/postgresql.conf
TmpConfFile=/tmp/postgresql.conf
sed $sedExp <$ConfFile >$TmpConfFile 2>$ErrFile;

if [ -s $ErrFile ]
then
  cat $ErrFile
else
  mv $TmpConfFile $ConfFile
fi

POSTGRES_PARAMS=''
if [ -n "$BACKUP_RESTORE" ]
then
  BACKUP_RESTORE_FILE="/var/lib/pgsql/data/BACKUP_RESTORE"
  OLD_BACKUP_RESTORE=
  if [ -f  $BACKUP_RESTORE_FILE ]
  then
    read OLD_BACKUP_RESTORE < $BACKUP_RESTORE_FILE
  fi
  if [ -n "$RESTORE_HOST" -a -n "$RESTORE_PASSWORD" -a "$BACKUP_RESTORE" != "$OLD_BACKUP_RESTORE" ]
  then
    if [ -z "$RESTORE_PORT" ]
    then
      export RESTORE_PORT=5432
    fi
    if [ -z "$RESTORE_USER" ]
    then
      export  RESTORE_USER='postgres'
    fi
    /bin/dumpRestoreAll.sh
    echo $BACKUP_RESTORE > $BACKUP_RESTORE_FILE
  else
    if [ "$BACKUP_RESTORE" == "$OLD_BACKUP_RESTORE" ]
    then
      echo "Режим бекапа BACKUP_RESTORE Повторный запуск сервиса с идентификатором $BACKUP_RESTORE. Бекап не производится"
    fi
    if [ -z "$RESTORE_HOST" ]
    then
      echo "Режим бекапа BACKUP_RESTORE Переменная RESTORE_HOST не определена. Бекап не производится"
    fi
    if [ -z "$RESTORE_PASSWORD" ]
    then
      echo "Режим бекапа BACKUP_RESTORE: Переменная RESTORE_PASSWORD не определена. Бекап не производится"
    fi
  fi
fi

if [ -n "$BACKUP_WALG" ]
then
  BACKUP_WALG_FILE="/var/lib/pgsql/data/BACKUP_WALG"
  OLD_BACKUP_WALG=
  if [ -f  $BACKUP_WALG_FILE ]
  then
    read OLD_BACKUP_WALG < $BACKUP_WALG_FILE
  fi
  if [ "$BACKUP_WALG" != "$OLD_BACKUP_WALG" ]
  then
    if [ -n "$WALG" -a -f "/etc/wal-g.d/server-$WALG.conf" ]
    then
      /bin/walgRestoreAll.sh
    else
      echo "Режим WALG=$WALG не поддержмивается"
    fi
  else
    if [ "$BACKUP_WALG" == "$OLD_BACKUP_WALG" ]
    then
      echo "Режим бекапа BACKUP_WALG. Повторный запуск сервиса с идентификатором $BACKUP_WALG. Бекап не производится"
    fi
  fi
fi

if [ -n "$WALG" -a -f "/etc/wal-g.d/server-$WALG.conf" ] # Включить режим архивирования WAL-G
then
  WALG_CONFFILE=~postgres/.walg.json
  . /etc/wal-g.d/server.conf
  . /etc/wal-g.d/server-$WALG.conf
    conf=`walg_conf_json`
    echo -ne $conf  > $WALG_CONFFILE
    chown postgres:postgres /bin/wal-g
    if [ -n "$WALG_FILE_PREFIX" ]
    then
      mkdir -p $WALG_FILE_PREFIX
      chown postgres:postgres $WALG_FILE_PREFIX
      chmod 777 $WALG_FILE_PREFIX
      ls -ld $WALG_FILE_PREFIX
    fi
    if [ -z "$WALG_PUSH_TIMEOUT" ]
    then
      WALG_PUSH_TIMEOUT=300
    fi
    while :;
    do
      su -s /bin/backup-push.sh postgres;
      su -s /bin/backup-delete.sh postgres;
      sleep $WALG_PUSH_TIMEOUT
    done &

    POSTGRES_PARAMS="-c archive_mode=on -c wal_level=replica -c archive_timeout=60 -c archive_command='/bin/wal-push.sh %p'"
#     POSTGRES_PARAMS="-c archive_mode=on -c wal_level=replica -c archive_timeout=60 -c archive_command='/bin/wal-push.sh %p'"
fi

exec su -c "/usr/bin/postgres -D /var/lib/pgsql/data $POSTGRES_PARAMS"  -s /bin/sh postgres


#!/usr/bin/env zsh

# WORKDIR: ../ (project root)
# ZDOTDIR: ../scripts/ (current dir)
# HISTFILE: ../tests/history.txt (set in `.zlogin`)

# pre-record
ln -fs ~/.zshrc ./scripts/.zshrc

# asciinema & control record
stty rows 25 columns 72
clear
asciinema rec \
  --overwrite ./images/zsh-record.cast \
  -c './scripts/control-record.zsh'

# post-record
rm -rf ./scripts/.zshrc ./scripts/.zsh_history ./scripts/.zcompdump-*


#!/bin/bash
rm -Rf codec-trunk
rm -Rf rl-glue-trunk
rm -Rf install_root


#!/bin/bash

# clone用のGitをcloneしてcommit用のGitリポジトリを作成する
git clone result updated-result

cd updated-result/
# 前Taskの出力結果をGitのcommit用のGit作業ディレクトリに移動する
mv -f ../out/* ./

git config --global user.email "<EMAIL>"
git config --global user.name "takuma02141978"

git add -A
git commit -m "Update result log"


<reponame>fenggeorgeyu/mapd-core<filename>scripts/common-functions.sh
#!/bin/bash

function download() {
    wget --continue "$1"
}

function extract() {
    tar xvf "$1"
}

function makej() {
    make -j $(nproc)
}

function download_make_install() {
    name="$(basename $1)"
    download "$1"
    extract $name
    if [ -z "$2" ]; then
        pushd ${name%%.tar*}
    else
        pushd $2
    fi

    if [ -x ./Configure ]; then
        ./Configure --prefix=$PREFIX $3
    else
        ./configure --prefix=$PREFIX $3
    fi
    makej
    make install
    popd
}

ARROW_VERSION=apache-arrow-0.10.0

function install_arrow() {
  download https://github.com/apache/arrow/archive/$ARROW_VERSION.tar.gz
  extract $ARROW_VERSION.tar.gz
  mkdir -p arrow-$ARROW_VERSION/cpp/build
  pushd arrow-$ARROW_VERSION/cpp/build
  cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DARROW_BUILD_SHARED=ON \
    -DARROW_BUILD_STATIC=ON \
    -DARROW_BUILD_TESTS=OFF \
    -DARROW_BUILD_BENCHMARKS=OFF \
    -DARROW_WITH_BROTLI=OFF \
    -DARROW_WITH_ZLIB=OFF \
    -DARROW_WITH_LZ4=OFF \
    -DARROW_WITH_SNAPPY=OFF \
    -DARROW_WITH_ZSTD=OFF \
    -DCMAKE_INSTALL_PREFIX=$PREFIX \
    -DARROW_BOOST_USE_SHARED=${ARROW_BOOST_USE_SHARED:="OFF"} \
    ..
  make -j $(nproc)
  make install
  popd

}

AWSCPP_VERSION=1.4.76

function install_awscpp() {
    # default c++ standard support
    CPP_STANDARD=14
    # check c++17 support
    GNU_VERSION1=`g++ --version|head -n1|awk '{print $4}'|cut -d'.' -f1`
    if [ "$GNU_VERSION1" = "7" ]; then
        CPP_STANDARD=17
    fi
    rm -rf aws-sdk-cpp-${AWSCPP_VERSION}
    download https://github.com/aws/aws-sdk-cpp/archive/${AWSCPP_VERSION}.tar.gz
    tar xvfz ${AWSCPP_VERSION}.tar.gz
    pushd aws-sdk-cpp-${AWSCPP_VERSION}
    patch -p1 < ${SCRIPTS_DIR}/aws-sdk-cpp-remove-git-version.patch
    mkdir build
    cd build
    cmake \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=$PREFIX \
        -DBUILD_ONLY="s3" \
        -DBUILD_SHARED_LIBS=0 \
        -DCUSTOM_MEMORY_MANAGEMENT=0 \
        -DCPP_STANDARD=$CPP_STANDARD \
        ..
    make $*

    # sudo is needed on osx
    os=`uname`
    if [ "$os" = "Darwin" ]; then
        sudo make install
    else
        make install
    fi

    popd
}


#!/bin/sh

################################################################################
#
# Ignore netlify PR builds for dependabot
#
################################################################################

git log -1 --pretty=%B | grep dependabot


<filename>dot.sh
dot -Tsvg dependency.dot > dependency.svg