Skip to content

Instantly share code, notes, and snippets.

const quicksort = (a) => {
if (a.length <= 1) {
return a
}
const pivot = a[0]
const low = []
const hi = []
a.map(i => {
i < pivot ? low.push(i) : null
i > pivot ? hi.push(i) : null
# bastion host jump ssh
ssh -i key.pem -J user@host user@host
@joshkitt
joshkitt / aws-sts-decode-authorization-messge.sh
Created October 22, 2021 17:44
AWS STS decode authorization message
aws sts decode-authorization-message --encoded-message (encoded error message) --query DecodedMessage --output text | jq '.'
@joshkitt
joshkitt / users.tf
Created August 2, 2021 17:17
Terraform for_each array list using format and index
locals {
users = [
"SCREENSM1",
"SCREENSM2",
"SCREENSM3",
"SCREENSM4",
"SCREENSA1",
"SCREENSA2",
"SCREENSA3",
"SCREENSA4",
@joshkitt
joshkitt / jvm-notes.txt
Last active July 21, 2021 16:58
JVM Memory
Maximum heap size:
If physical memory size is up to 192 megabytes (MB) then default maximum heap size is half of the physical memory.
If physical memory size is more than 192 megabytes then default maximum heap size is one fourth of the physical memory.
Initial heap size: At least 8 MB or 1/64th of physical memory up to a physical memory size of 1 GB.
java -XX:+PrintFlagsFinal -version | grep HeapSize
The default thread stack size varies with JVM, OS and environment variables.
java -XX:+PrintFlagsFinal -version | grep ThreadStackSize
@joshkitt
joshkitt / globalprotect-disable.txt
Created March 11, 2021 21:32
GlobalProtect - disable run at load and keep alive
sudo vi /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist
- Change “RunAtLoad” and “KeepAlive” to <false/>
sudo vi /Library/LaunchAgents/com.paloaltonetworks.gp.pangps.plist
- Change “RunAtLoad” to <false/>
@joshkitt
joshkitt / shadow-dom-css-override.js
Created February 11, 2021 22:59
Shadow dom css override
(function shadowLoop () {
var host = document.getElementsByTagName('host-element-containing-shadow-root)[0];
if (!host) {
setTimeout(shadowLoop, 500);
} else {
var style = document.createElement('style');
style.innerHTML = '#SomeID {display: none !important}';
host.shadowRoot.appendChild(style);
}
} ());
@joshkitt
joshkitt / multipass-resize.sh
Last active December 24, 2020 01:34
Multipass - Resize a multipass instance on MacOS
sudo /Applications/Docker.app/Contents/MacOS/qcow-tool resize --size=$(( 12 * 1024 * 1024 * 1024 )) "/var/root/Library/Application Support/multipassd/vault/instances/blissful-glowworm/ubuntu-20.04-server-cloudimg-amd64.img"
ssh -M -S /tmp/db-socket -fnNT -L 3306:[RDS_ENDPOINT]:3306 [USER]@[BASTION_HOST]
@joshkitt
joshkitt / aws-ec2-userdata-java.sh
Last active July 30, 2020 15:19
AWS EC2 User Data with Java
#!/bin/bash
sudo su
yum update -y
yum install -y httpd
amazon-linux-extras install java-openjdk11
systemctl start httpd.service
systemctl enable httpd.service
EC2_AVAIL_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
echo "<h1>Hello World from $(hostname -f) in AZ $EC2_AVAIL_ZONE </h1>" > /var/www/html/index.html