Skip to content

Instantly share code, notes, and snippets.

View kloudsamurai's full-sized avatar
:electron:
Fine tuning the future

David Maple kloudsamurai

:electron:
Fine tuning the future
View GitHub Profile
@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/..";
# 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/..";
@kloudsamurai
kloudsamurai / remove_service_workers.js
Created January 30, 2019 08:13
Remove all installed service workers
if (typeof window !== 'undefined' && 'serviceWorker' in navigator) {
window.navigator.serviceWorker.getRegistrations().then(registrations => {
registrations.forEach(r => r.unregister())
})
}
exports.handler = (event, context, callback) => {
context.succeed({
statusCode: 200,
headers: {
"Content-Type" : "image/png"
},
body: "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAA4pklEQVR4Ae2dd1xUd9b/LwWxY++KxnSjMRtN302yMSXrpuTZjfntZpM1m90YjRQYCgPMwEjvIoqKvaPYCxZAsceuiAXFgoACoShz7/S58/vcPCS7Ppgswgxc7pw/3i99Ucbhcs/b7/fc8z2HsVgsRBuzPXunc6Bc8Un4jKg14ADYDZL9AuQvVVfXONM1aj3MlZccWP9Og7gZwyeDcKBg5T0+0GeHdqPr0/bQRWhjcvP2jYWsjkJQJmAGfANmYJwRGXNSHqJ8S6vV0fWyIby6ioGYxnGRI3dDUkZgAuYGTFzEIyWsvOfnhoOz7fMakbCIg4cOjw0ICj3RICjLL8ADY0RUbIYyPLITXTcrYzYwrHJAVy7qsQXcDHcD5MQDy4NxN7JB3f0N3y+yr2tEwiKOHT/hBlmt/GVZNcIEzkdExQym62c9ONXwxyCiSw0rKst/ReV+j5W7fWo8udI+rhEJizh16gwTGKz4e5gq0ijI6CHgQUlsfOKTdB1bjib6iRchoKrGq6pfBzmu7cZTa4bRNSRh2QXHj5/sJQuQrxIk1EzKEpNTR9K1bD6ahLHPQ1Z1jYTUtFWWiQ3u9Tfj+c10LUlY0ufMmXNv+foHVQjyaQFXZs1O70/X8+HRzHx5LLaBdwT5NBfWv+NC49msHnQ9SViS5nzhBSY4NGwatoN8C4XF4zVOzJ2/sANd16ajnfP7YZDVjZbIqmFbWAhh/YauKQlL0pw5e66rr1/gPEE6VsAEaWUvXrqcrm0T0C74Yzds584KwmkprJ+ryXQx+xOpXzMSF
openssl s_client -connect owapi.net:443 </dev/null
ex +'g/BEGIN CERTIFICATE/,/END CERTIFICATE/p' <(echo | openssl s_client -showcerts -connect ) -scq > comodo-ecc-ca.cert
keytool -import -file comodo-ecc-ca.cert -alias comodo-ecc-ca -keystore truststore