Skip to content

Instantly share code, notes, and snippets.

@joshkitt
joshkitt / weasyprint.py
Created February 19, 2025 21:54
Weasyprint Lambda
#!/usr/bin/env python
import base64
import os
from weasyprint import CSS, HTML
def lambda_handler(event, context):
filename = event["filename"]
basename = os.path.basename(filename)
@joshkitt
joshkitt / openssl-extract.sh
Last active August 14, 2024 16:53
Extract certificate key, certificate, and certificate chain from a pfx tls certificate file
openssl pkcs12 -in cert.pfx -nocerts -nodes | sed -ne '/-BEGIN PRIVATE KEY-/,/-END PRIVATE KEY-/p' > cert.key
openssl pkcs12 -in cert.pfx -clcerts -nokeys | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > cert.cer
openssl pkcs12 -in cert.pfx -cacerts -nokeys -chain | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > chain.cer
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"