Skip to content

Instantly share code, notes, and snippets.

@gilfreund
gilfreund / macEsc.sh
Created July 17, 2019 08:39
Map §± key to esc on Mac OSX
#!/bin/bash
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000029}]}'
@gilfreund
gilfreund / launchEC2spot.sh
Last active April 5, 2024 23:12
Launch an EC@ instance the get the intance ID and IP
#!/bin/bash
LAUNCHTEMPLATEID=lt-04f7a88addea07001
INTANCETYPE=p3.2xlarge
REGION=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone | cut -c1-9)
AWSCMD="aws --region $REGION --output text
IMAGEID=$($AWSCMD ssm get-parameters --names /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2 | cut -f 6)
TAGVALUEOWNER=$($AWSCMD iam get-user| awk '{printf $7}')
SNAPSHITID=$($AWSCMD ec2 describe-images --image-id $IMAGEID | grep snap- | awk -F" " '{print $4}')
@gilfreund
gilfreund / lvmount.sh
Last active April 5, 2024 23:12
Automatically mount EC2 free ephemeral disks into an LVM group
#!/bin/bash
# based on code byLeon Mergen
# see: https://leonmergen.com/automatically-mounting-instance-store-on-an-aws-ami-150da3ffd041
LVDISPLAY=$(which lvdisplay)
PVCREATE=$(which pvcreate)
VGCREATE=$(which vgcreate)
LVCREATE=$(which lvcreate)
MOUNT=$(which mount)
MKDIR=$(which mkdir)