Skip to content

Instantly share code, notes, and snippets.

@kloudsamurai
kloudsamurai / intellij_database_advanced_settings_rds_aurora.txt
Created December 30, 2021 06:39
IntelliJ Database Advanced Settings for RDS/Aurora
enabledTLSProtocols=TLSv1,TLSv1.1,TLSv1.2,TLSv1.3
@kloudsamurai
kloudsamurai / gradle.properties
Created December 22, 2021 03:01
gradle.properties for high memory allocation
#Enable daemon
org.gradle.daemon=true
# Try and findout the best heap size for your project build.
org.gradle.jvmargs=-Xmx18G -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options=-Xmx18G
# Modularise your project and enable parallel build
org.gradle.parallel=true
# Enable configure on demand.
org.gradle.configureondemand=true
@kloudsamurai
kloudsamurai / gradle_test_log4j_CVE-2021-44228.sh
Last active December 12, 2021 17:52
Test Gradle Dependencies for CVE-2021-44228: Log4j Zero Day Vulnerability
gradle dependencyInsight --dependency log4j-core
wget https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
keytool -keystore amazon.jks -importcert -file ./global-bundle.pem
# note: remember this password -- you'll need it in intellij
@kloudsamurai
kloudsamurai / install_maven_cloud9.sh
Last active January 5, 2020 01:47
Install Maven3 on Amazon Linux Cloud9
#!/usr/bin/env bash
cd /tmp
MVN_VERSION="3.6.3"
wget https://www-eu.apache.org/dist/maven/maven-3/$MVN_VERSION/binaries/apache-maven-$MVN_VERSION-bin.tar.gz
sudo mkdir /usr/local/apache-maven
tar -xzf apache-maven-$MVN_VERSION-bin.tar.gz
sudo cp -r apache-maven-$MVN_VERSION /usr/local/apache-maven
@kloudsamurai
kloudsamurai / install_gradle_cloud9.sh
Last active December 10, 2021 19:11
Install Gradle on Amazon Linux Cloud9
#!/bin/bash
gradle_version=7.3.1
wget -c https://services.gradle.org/distributions/gradle-${gradle_version}-bin.zip
sudo unzip gradle-${gradle_version}-bin.zip -d /opt
sudo ln -s /opt/gradle-${gradle_version} /opt/gradle
printf "export GRADLE_HOME=/opt/gradle\nexport PATH=\$PATH:\$GRADLE_HOME/bin\n" | sudo tee /etc/profile.d/gradle.sh
source /etc/profile.d/gradle.sh
# check installation
gradle -v
DELIMITER |
CREATE FUNCTION bin_to_uuid(b BINARY(16))
RETURNS CHAR(36) DETERMINISTIC
BEGIN
DECLARE hex CHAR(32);
SET hex = HEX(b);
RETURN CONCAT(LEFT(hex, 8), '-', MID(hex, 9,4), '-', MID(hex, 13,4), '-', MID(hex, 17,4), '-', RIGHT(hex, 12));
END
|
@kloudsamurai
kloudsamurai / cloudfront_session_id_lambda.js
Created May 9, 2019 22:37
Amazon AWS Cloudfront Lambda @ Edge to Manage Session ID Creation and Updates
'use strict';
const crypto = require("crypto");
const sessionKey = 'CLOUDFRONT_SESSION_ID';
const regex = '(^|[^;]+)\\s*' + sessionKey + '\\s*=\\s*([^;]+)';
const expirationMinutes = 2 * 60; // 2 hours
const SHTS = 'Strict-Transport-Security';
function getSessionCookie(cookieValue) {
@kloudsamurai
kloudsamurai / encrypt_decrypt_gpg_passphrase_example.sh
Last active October 3, 2021 09:59
Using GPG with a passphrase to encrypt and decrypt with AES256
# encrypt secret.txt
gpg --symmetric --yes --batch --cipher-algo AES256 --passphrase=XXXXX secret.txt && rm -f secret.txt
# decrypt secret.txt
gpg --decrypt --yes --batch --passphrase=XXXXX secret.txt.gpg > secret.txt && rm -f secret.txt.gpg
# function to test for parent directories
__has_parent_dir () {
test -d "$1" && return 0;
current="."
while [ ! "$current" -ef "$current/.." ]; do
if [ -d "$current/$1" ]; then
return 0;
fi
current="$current/..";