Skip to content

Instantly share code, notes, and snippets.

View siberex's full-sized avatar
⚙️
ngen earring or something

Stephen Jingle siberex

⚙️
ngen earring or something
View GitHub Profile
@siberex
siberex / check_urls.sh
Last active November 12, 2020 00:47
Check list of URLs
#!/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.
# 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"
/**
* 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
@siberex
siberex / gen_honeypot_urls.sh
Last active June 24, 2024 06:00
Honeypot URLs
#!/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
@siberex
siberex / generic.sh
Last active December 1, 2022 07:11
Generic bash script stuff
#!/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
@siberex
siberex / cancelot.sh
Last active July 29, 2024 21:40
Provides automation for cancelling previous ongoing Cloud Builds for the same branch/trigger
#!/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
@siberex
siberex / verify-hits.sh
Created April 6, 2020 01:33
Verify number of remote hits from Bazel execution log
#!/usr/bin/env bash
# https://gist.github.com/siberex/1488492ceb193d936b6bd171fc1a879f
# Verify number of remote hits from execution log produced by:
# bazel build ... --execution_log_json_file=/tmp/execlog.json
# Usage:
# verify-hits.sh 123
# OR:
# verify-hits.sh 100 /tmp/execlog.json
@siberex
siberex / wait-for-file.sh
Last active May 28, 2020 15:12
Wait for file to become readable
#!/usr/bin/env bash
# https://gist.github.com/siberex/d1c07389333d9cdb1c9e6853ec70c98b
# Wait for file to become readable
# Similar to https://github.com/vishnubob/wait-for-it
# Usage:
# wait-for-file.sh -t 10 -p /tmp/something -- echo "ok"
WAITFORIT_cmdname=${0##*/}
@siberex
siberex / fix-execlog-json.sh
Last active April 1, 2020 00:54
Fix json file produced by Bazel’s --execution_log_json_file argument
#!/usr/bin/env bash
# https://gist.github.com/siberex/55f277071068179de026e6cf29c0584a
# Usage:
# bazel build //... --execution_log_json_file=/tmp/execlog.json
# fix-execlog-json.sh /tmp/execlog.json
# Exit script when command fails
set -o errexit
@siberex
siberex / Dockerfile
Last active March 31, 2020 21:57
Angular 9 Bazel build test
# https://hub.docker.com/r/sibli/bazel-test
FROM l.gcr.io/google/bazel:2.2.0 AS builder
# Add Bazelisk
RUN curl -L -o /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.3.0/bazelisk-linux-amd64 \
&& chmod +x /usr/local/bin/bazel
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -