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
/** | |
* Performs a recursive depth-first listing of an S3 prefix | |
* @param client the S3 client to use | |
* @param bucketName the name of the S3 bucket | |
* @param prefix the prefix to start from | |
*/ | |
public static void listPrefix(S3AsyncClient client, String bucketName, String prefix) { | |
client.listObjectsV2Paginator(b -> b.bucket(bucketName) | |
.prefix(prefix) | |
.delimiter("/")) |
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
#! /bin/bash | |
# See https://www.atamanroman.dev/articles/jvm-memory-settings-container-environment/ | |
# set at 75% then print the flag values and grep for heapsize and max ram | |
java -XX:MaxRAM=$(( $(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) * 75 / 100 )) -XX:MaxRAMFraction=1 -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram" |
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
#!/bin/bash | |
awscurl https://<HOST>:8182/status \ | |
--service neptune-db \ | |
--access_key $AWS_ACCESS_KEY_ID \ | |
--secret_key $AWS_SECRET_ACCESS_KEY \ | |
--region us-east-1 |
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/local/bin/bash | |
# Gets a set of temporary credentials for an EC2 using a named profile that the instance profile of the EC2 is allowed | |
# to assume. Sourcing the script will set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN | |
# usage: source temporary_creds.sh <service_role_name> | |
if [ -z "$1" ]; then echo "usage: source creds.sh <service_role_name>"; fi | |
service_role_name=$1 |
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
#! /bin/bash | |
# This script makes it easier to maintain security groups that allow SSH access | |
# from a computer with a dynamic IP, such as a computer on a home network or ISP. | |
# | |
# Using the script will allow you to SSH to an EC2 without having to allow | |
# access to the whole world (0.0.0.0/0). If you run this script whenever your IP | |
# changes then the security groups in your account specified by your AWS profile | |
# will be updated. | |
# |
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
aws ecs update-cluster-settings --cluster CLUSTER-NAME --settings name=containerInsights,value=enabled |
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
# Manage Docker as a non-root user | |
# Stolen from https://askubuntu.com/a/477554 | |
# | |
# The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user. | |
# | |
# If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group. | |
# | |
# Add the docker group if it doesn't already exist: | |
sudo groupadd docker |
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
# this example is from https://unix.stackexchange.com/a/137639/322623 | |
function fail { | |
echo $1 >&2 | |
exit 1 | |
} | |
function retry { | |
local n=1 | |
local max=5 |
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
#!/bin/bash | |
#exit on any line causing an error | |
set -e | |
#trap any exit or error and handle with the final() function | |
trap 'final $? $LINENO' EXIT | |
final() { | |
#write the return code |
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
<configuration> | |
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
<!-- encoders are assigned the type | |
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
<encoder> | |
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | |
</encoder> | |
</appender> |
NewerOlder