input = input.split('\n').map(v => parseInt(v));
for (let i = 0; i < input.length; i++) {
const a = input[i];
for (let j = i + 1; j < input.length; j++) {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 3.8+ | |
# https://docs.bazel.build/versions/master/platforms.html#skipping-incompatible-targets | |
# https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes | |
# Pre 3.8: | |
# | |
# Bazel Platforms Cookbook: | |
# https://docs.google.com/document/d/1UZaVcL08wePB41ATZHcxQV4Pu1YfA1RvvWm8FbZHuW8/edit# | |
# | |
# Use this only for simple cases like skipping Windows-only targets on Linux CI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# App Engine: List all project regions and mapped domains | |
# Effectively: | |
# gcloud projects list --format 'get(PROJECT_ID)' | |
# gcloud app describe --project "$projectId" --format 'get(locationId)' | |
# gcloud app domain-mappings list --project "$projectId" --format 'get(ID)' | xargs | sed 's/ /, /g' | |
printf "%s\t%s\t%s\n" "ProjectId" "Region" "Domains" | |
gcloud projects list --format 'get(PROJECT_ID)' | while read -r projectId; do | |
region=$(gcloud app describe --project "$projectId" --format 'get(locationId)' 2>/dev/null || echo 'N/A') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
# For a set of provided URLs, measure average response time for each one. | |
# https://gist.github.com/siberex/9adb939b1c7872404672697ee7985188 | |
NUM_REQUESTS=100 | |
URLS=() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
CMD_NAME=${0##*/} | |
usage() { | |
cat <<USAGE >&2 | |
Check each URL from list of URLs. | |
Prints out if HEAD request were successful or not. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find which jar file contains specific Java class or package | |
WHERE=$JAVA_HOME | |
WHAT="org.graalvm.polyglot" | |
for f in $(find "$WHERE" -name '*.jar' -type f); do echo $f >&2 && "$JAVA_HOME/bin/jar" tvf $f; done | grep "$WHAT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Egg-dropping problem. | |
* You have limited number of (crystal) eggs and limited number of throws, | |
* and want to check some tower, determining highest floor where egg | |
* will not break when thrown from there. | |
* | |
* This function will tell the max height of the building which could be tested | |
* with the given number of eggs and throws. | |
* | |
* @param n int Number of eggs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Retrieves list of files larger than 600 MB from linux distros mirror | |
# Saves maximum 10 random links for each distro in the output.txt file | |
# Usage: | |
# gen_honeypot_urls.sh | |
# or: | |
# gen_honeypot_urls.sh /path/to/out.txt | |
# Exit script when command fails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Exit script when command fails | |
set -o errexit | |
# Exit when script tries to use undeclared variable | |
set -o nounset | |
# Exit if piped command fails | |
set -o pipefail | |
# aka: | |
# set -euo pipefail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# https://github.com/siberex/cancelot | |
# | |
# To download the latest version (if you trust running random bash scripts from the internets!): | |
# curl -L https://gist.github.com/siberex/bb0540b208019382d08732cc6dd59007/raw -o cancelot.sh && chmod +x cancelot.sh | |
# | |
# Provides automation for cancelling Cloud Builds | |
# Use as a first step to cancel previous builds currently in progress or queued for the same branch name and trigger id. | |
# Similar to: https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/cancelot |